Linux find command – Find file and directories faster and easier

2010-03-16 1 min read Linux

 

This command is very powerfull when used with combination of filters and pipes and RE.

I will give some example:

find . -type f –» List all files
find . -type f -exec rm {} <a class=“zem_slink” title=“Path (computing)” href=“http://en.wikipedia.org/wiki/Path_%28computing%29" rel=“wikipedia”>\; –» Delete all files
find . -type d -exec rm {} \; –» Will through some common errors 🙂
find . -name "name"  –> find files containing name in the filename
find . -atime 12 –> Find files accessed 12 days ago

Similarly there is ctime for file status change

find . -type d -depth 2 –> find all the directories in the depth 2 of the tree.
find . -tyde d -ok rm -rf {} \; –> Delete all the directories but only after user confirmation

There could be numerous such examples so I will leave it to you do digg the man page for find and then experiment :))

\"Reblog
Enhanced by Zemanta
comments powered by Disqus