info home general windows unix linux debian mac os apache nginx iphone

Recent Articles

How to rename multiple files in Unix or Linux

Convert docx to doc in Mac OS X Snow Leopard or Leopard

HISTORY shell variable management in Unix/Linux

How to eject CD/DVD from your MacBook or iMac

Play Prince of Persia on Ubuntu Linux using DOSBox

Tags

Unix find command with examples and common usage

All these examples search for files under the location /apps

file name and strings

search for files named server.properties

find /apps -name server.properties

search for string "JAVA_HOME" in all files

find /apps -exec grep "JAVA_HOME" '{}' /dev/null \; -print

search for files by user USER123

find . -user USER123

file size

Find files greater than 1GB

find /apps -size +1024000k -print

Find files greater than 1GB and

find /apps -type f -size +1024000k -exec ls -al {} \;

files last modified

Find files modified less than 7 days back

find /apps -mtime -7 -print

Find files modified longer than 7 days ago

find /apps -mtime +7 -print

file permissions

Find files that are executable

find /apps -perm -100 -print

Find files that have permissions -r--r--r--

find /apps -perm 444 -print

Find directories that have write permissions

find /apps -type -perm 777 -print

files with extensions

Search for *.log files under /apps

find /apps -name '*.log' -print

files by type

Search for softlinks

find /apps -type l -print | xargs ls -l

using xargs

Find files with executive permission and remove the x permission for groups and others

find /apps -perm -20 -exec chmod go-x {} ;

You can also use this:

find /apps -perm -20 -print | xargs chmod go-x

Last Update: 2 September 2009