Sunday 14 June 2015

Find Command

How to find for a file using name?

find -name "sum.txt"
./bkp/sum.txt
./sum.txt
-i can be used for case insensitive file names.

How to remove files which contain the name "java".

find -name "*java*" -exec rm -r {} \;

This will delete all the files which have the word “java" in the file name in the current directory and sub-directories.

How to find for a file in the current directory only?

find -maxdepth 1 -name "sum.txt"

No comments:

Post a Comment