Find Command

I am gonna create some mixed name files for the demo

touch test.txt Test.Txt TeSt.TxT TEST.TXT

Now we can find the exact file we want using find command find . -type f -name "filename".

find . -type f -name "Net.conf"
find /etc -type f -name "T*.Txt"
find /etc -type f -iname "T*.Txt"



use . to find in a current directory


f for files
d for dir

or if you skip type it will find files & directory both.
-name for sensitive name-iname for non-sensitive name
"in quotes" file or dir name 

Finding Permissions
find /etc -type f -perm 0664
0 6 4 4  rw r r




Using size Argument

find . -size +20M

+100k for over 100k

you can use exact 100k or 1m, -1m, +1m, -100k.




Using not Argument

if i want to find find all files but not txt then we can use -not.

find . -type f -not -iname "*.txt"




By default find command finds recursively but if we dont want to find recursively then we can use -maxdepth.

find /etc -maxdepth 1 -type f -name "*.conf"

or -maxdepth 2,3.



No comments:

Post a Comment

Popular Posts