Useful find commands

posted Apr 29, 2012, 7:29 AM by Sachchida Ojha   [ updated May 22, 2013, 9:14 AM ]

1. Locate files that contains certain strings

$ find . -print|xargs grep -i v\$session (find files containing v$session)

2. Find recently created files

$find . -mtime -1 -print ( shows files created during the past day)

3. Find large files on server

$find . -size  +10000 -print (file size greater than equal to 10,000 bytes)

4. Delete file in bulks


$find . -mtime +7 -exec rm {} \; (delete all files older than 7 days).

5. allocate an empty files

$touch new.txt

6. Find all files owned by a specific user

$find /  -user sachi

7. Find all directories named 'conf'

$find / -type d -name conf

8. Find all files larger than 500k


$find -name '*' -size +500k


Comments