Linux find usage

#syntax
#find [SETTINGS] PATH [EXPR]

#write all files
find

#write all files in specified diretory
find /usr/dev

#write files with extension .pro
find /usr/dev -name "*.pro"

#write "file"
find /usr/dev -name "*.pro" | echo file

#wite file followed by all files in ONE row
find /usr/dev -name "*.pro" | xargs echo file

#write found file to specified position in echo command (char $ can be raplaced by anything else, for examle {} )
find /usr/dev -name "*.pro" | xargs -I $ echo file: $

#change date time in all *.pro files 
find /usr/dev -name "*.pro" | xargs -I $ touch -t 201208131010 $

#find specified texts in files
grep "text" *.pro

#find texts and write also a file name
grep -H "text" *

#write only file names (really don't know how it works 😉 )
grep -h "text" * | cut -d: -f1

#change privileges for files with content
grep -h "text" * | cut -d: -f1 | xargs -I $ chmod 777 $

Leave a Reply

Your email address will not be published. Required fields are marked *