Download as:
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Language:EN

Reference: find

UNIX in a Nutshell: System V Edition

 

find

find pathname(s) condition(s)
-atime +n | -n | n
-cpio dev
-ctime +n | -n | n
-depth
-exec command {} \;

Run the Unix command on each file matched by find, provided command executes successfully on that file; i.e., returns a 0 exit status. When command runs, the argument {} substitutes the current file. Follow the entire sequence with an escaped semicolon (\;).

-follow

Follow symbolic links and track the directories visited (don't use this with -type l).

-fstype type
-group gname
-inum n
-links n
-local

Find files that physically reside on the local system.

-ls

Display matching files with associated statistics (as if run through ls -lids).

-mount
-mtime +n | -n | n
-name pattern
-ncpio dev
-newer file

Find files that have been modified more recently than file; similar to -mtime.

-nogroup

Find files belonging to a group not in /etc/group.

-nouser
-ok command {} \;
-perm nnn
-print

Print the matching files and directories, using their full pathnames. On Solaris, this is the default.

-prune

"Prune" the directory tree of unwanted directory searches; that is, skip the directory most recently matched.

-size n[c]
-type c
b Block special file
c Character special file
d Directory
D Door special file, Solaris only
f Plain file
l Symbolic link
p Fifo or named pipe
s Socket
-user user
-xdev

Examples

List all files (and subdirectories) in your home directory:

find $HOME -print

List all files named chapter1 underneath the /work directory:

find /work -name chapter1 -print
find /work /usr -name 'memo*' -user ann -print
find / -type d -name 'man*' -print
find . \! -name '[A-Z]*' -exec lp {} \;
compress `find . -type f \! -name '*.Z' -print`

Remove all empty files on the system (prompting first):

find / -size 0 -ok rm {} \;

Skip RCS directories, but list remaining read-only files:

find . -name RCS -prune -o -perm 444 -print
find / -mtime -2 -print
find /book -print | xargs grep '[Nn]utshell'


The UNIX CD Bookshelf Navigation
Copyright © 2009-2023 UrgentHomework.com, All right reserved.