GNU Find

find
$ touch x.x               # set date(s) of x.x to "now" 


find by date of existing file
$ find . -anewer x.x    # (a)ccessed after x.x/now
$ find . -cnewer x.x    # "file status" (c)hanged after x.x/now
$ find . -newer x.x     # newer/modified after x.x/now


numeric time arguments
-N less than / up to N days/mins
+N more than N days/mins ago
N exactly N days/mins ago (not very useful !)


find by days (n*24hrs)
$ find . -atime -7 -exec ls -l {} \;      # (a)ccessed in the last week
$ find . -ctime +31 -exec ls -l {} \;     # "file status" (c)hanged more than a month ago
$ find . -mtime +1090 -exec ls -l {} \;   # (m)odified more than 3 years ago


find by minutes
recursively find files by date time
$ find . -amin -15 -exec ls -l {} \;     # (a)ccessed in the last qtr hour
$ find . -cmin +30 -exec ls -l {} \;     # "file status" (c)hanged more than half an hour ago
$ find . -mmin +45 -exec ls -l {} \;     # (m)odified more than 45 mins ago


find names
handle files with spaces and other problem characters with null char
$ find . -name "a*" -print0 > filelist


find & grep
recursively find and search / grep files
$ find . -name "*.php" -exec grep -H <searchstring> {} \;


find & ls & rm
recursively find *.LCK files for the current user list them and then remove them
$ find . -user $USER -name "*.LCK" -exec ls -lG {} \; 
$ find . -user $USER -name "*.LCK" -exec rm {} \; 



REFERRERS
GnuCoreUtils
GnuTextUtils
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki