Monday 15 August 2011

find

From current directory
find . -name 'my*'


Files only
find . -name "my*" -type f


Specify a directory
find /home/weedly -name "myfile" -type f -print

Find any one of differently named files
find . \( -name "*jsp" -o -name "*java" \) -type f -ls



Execute an action
find /var/ftp/mp3 -name "*.mp3" -type f -exec chmod 644 {} \;

Search for a string
This command will search for a string in all files from the /tmp directory and below:
find /tmp -exec grep "search string" '{}' /dev/null \; -print




Search files by size
Example of searching files with size between 100 kilobytes and 500 kilobytes.
find . -size +100k -a -size -500k

No comments:

Post a Comment