Mehic.info

Linux or UNIX – Find and remove file syntax

To remove multiple files such as *.jpg or *.sh with one command find, use

find . -name “FILE-TO-FIND”-exec rm -rf {} \;

OR

find . -type f -name “FILE-TO-FIND” -exec rm -f {} \;

The only difference between above two syntax is that first command can remove directories as well where second command only removes files.

 

To find content of file use :

find . -type f | xargs grep -l “Your text here”

To find and replace:

find ./ -type f -exec sed ‘s,file:///home/miralem/ns3/ns-3-dev/doc,http://www.qkdnetsim.info/doc,g’ {} \;