Differences between revisions 2 and 3
Revision 2 as of 2023-07-23 19:21:44
Size: 1182
Comment:
Revision 3 as of 2023-08-21 02:24:28
Size: 1174
Comment:
Deletions are marked like this. Additions are marked like this.
Line 46: Line 46:
find . --user foo -exec chown bar {} \; find . -user foo -exec chown bar {} \;
Line 52: Line 52:
find . --group foo -exec chgrp bar {} \; find . -group foo -exec chgrp bar {} \;
Line 62: Line 62:
find . --type d --perm 755 find . -type d -perm 755
Line 68: Line 68:
find . --type f --not --perm 644 --exec chmod 644 {} \; find . -type f -not -perm 644 -exec chmod 644 {} \;

Find

find(1) is a file finder.


Installation

find(1) will be pre-installed on any Linux or BSD operating system, as a POSIX utility.


Usage

find(1) identifies files and, by default, simply prints them.

find(1) can alternatively execute a command on the file name. Note that this occurs in a subshell, so functions and environment variables are not accessible to the command.

find . --exec mv ../backup/{} \;

File Name

To find all files with a name matching a pattern, try:

find . -name '*.pyc' -exec rm {} \;

File Ownership

To find all files owned by user foo, try:

find . -user foo -exec chown bar {} \;

To find all files in the group foo, try:

find . -group foo -exec chgrp bar {} \;

File Permissions

To find all files with some permission level, try:

find . -type d -perm 755

Conversely, to find all files with any other permission level, try:

find . -type f -not -perm 644 -exec chmod 644 {} \;


CategoryRicottone

Find (last edited 2024-12-28 15:42:20 by DominicRicottone)