Showing posts with label find. Show all posts
Showing posts with label find. Show all posts

Wednesday, July 11

"find" and "grep" command


"find" command is used to search for files. you can specify many options with it like files created today or having size greater then you specified. Normally we also combine find with xargs or exec to issue commands on files returned by find.
examples of find command:
* find top 10 largest files in /var:
$ find /var -type f -ls | sort -k 7 -r -n | head -10

* find all files having size more than 5 GB in /var/log/:
$ find /var/log/ -type f -size +5120M -exec ls -lh {} \;
* find all today’s files and copy them to another directory:
$ find /home/me/files -ctime 0  -print -exec cp {} /mnt/backup/{} \;