Find command examples
http://linux.about.com/od/commands/l/blcmdl1_find.htm
find [path...] [expression]
The expression is made up of options, tests and actions
find . -name "rc.conf" -print
find . -name "rc.conf" -exec chmod o+r '{}' \;
find . -exec grep "www.athabasca" '{}' \; -print
find . -exec grep -q "www.athabasca" '{}' \; -print
find /usr/src -not \( -name "*,v" -o -name ".*,v" \) '{}' \; -print
This command will search in the /usr/src directory and all sub directories. All files that are of the form '*,v' and '.*,v' are excluded.
find -maxdepth 2 -type f
find -type f ! -perm -444 // Find files not readable by all (useful for web site)
find / -name core -exec rm -f {} \;
find / -name core -print | xargs rm -f # more efficient than the previous one
http://linux.about.com/od/commands/l/blcmdl1_find.htm
find [path...] [expression]
The expression is made up of options, tests and actions
find . -name "rc.conf" -print
find . -name "rc.conf" -exec chmod o+r '{}' \;
find . -exec grep "www.athabasca" '{}' \; -print
find . -exec grep -q "www.athabasca" '{}' \; -print
find /usr/src -not \( -name "*,v" -o -name ".*,v" \) '{}' \; -print
This command will search in the /usr/src directory and all sub directories. All files that are of the form '*,v' and '.*,v' are excluded.
find -maxdepth 2 -type f
find -type f ! -perm -444 // Find files not readable by all (useful for web site)
find -name '*' -size +1000k
In the above example the system would search for any file that is larger then 1000k.
find /home -user joe
find $HOME -mtime 0
Search for files in your home directory which have been modified in
the last twenty-four hours.
find / \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \
\( -size +100M -fprintf /root/big.txt '%-10s %p\n' \)
Traverse the filesystem just once, listing setuid files and
directories into /root/suid.txt and large files into
/root/big.txt.
find . -atime +7 -o -size +`expr 10 \* 1024 \* 2` -print
this command was looking for any files in the current directory and its subdirectories (represented by .) that have not been accessed for more than 7 days (-atime +7) or (-o) that were greater than a certain size (-size +).find / -name core -exec rm -f {} \;
find / -name core -print | xargs rm -f # more efficient than the previous one

0 Comments:
Post a Comment
<< Home