find ~ -type f -name ".*"
|
FIND the hidden files in your home directory (~) |
find . -name *~ -type f -delete
|
Delete all files ending in ~ |
find . -name *.svn -type d -print0 | xargs -0 /bin/rm -rf |
Delete all .svn files under current dir |
find . -name *.c -perm /u+x -type f -print0 | xargs -0 chmod 644 |
Change wrong exec permissions on all .c files |
find / -perm 1644 |
FIND all files with SUID bit set (1664 or u=s). This searches ALL files in the system (/). |
find / -maxdepth 2 -perm /u=s 2>/dev/nul
|
Same as above but limit depth to 2 dirs down from / and discard all the error messages. |
find . -type f '!' \( -name '*/.git/*' -name '*.c*' -o -name '*.h' \) -print0|xargs -0 -e grep -nHi -e dvb |
FIND all .c or .h files containing case-insensitive text ‘DVB’ except for those in the .git subdir. Format output for emacs search window. Replace -name by -wholename if ‘find’ complains about slashes in UNIX names. |
find . -type f '!' \( -wholename '*/.git/*' -o -name "*.o" \) | xargs -e grep -nH -w -B5 -A10 dvbt2 |
FIND word ‘dvbt2’ in all files except .o files and those in the .git directory and print 5 lines before and 10 lines after the string matches |
find . -type f '!' \( -wholename '*/.git/*' -o -name "*.o" \) -exec grep -nH -B5 -A10 -w -e dvbt2 {}\; |
… same as previous command but using find’s -exec switch |
More ‘find’ command tutorials, how-to’s and examples:
http://www.binarytides.com/linux-find-command-examples/
http://alvinalexander.com/unix/edu/examples/find.shtml
http://www.tecmint.com/35-practical-examples-of-linux-find-command/