notes: Linux commands sed, find, grep combination is super powerful

I needed to bulk replace some text in thousands of files, yet skip some directories. Ended up using grep / sed combination. Also used find for some other purpose. Just noting down here for my future reference.

 grep -iRl --exclude-dir={skipme1,log} FindMeInFiles .  | xargs sed -i 's/IamBad/IamGood/g'
find -L -type f -print0 |xargs -0 sed -i.bak 's/IamBad/IamGood/g’


find -L -type f -print0 |xargs -0 sed -i 's/IamBad/IamGood/g’

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.