Sunday, January 06, 2013

Linux command to replace string in all files in directory

    grep -rl 'string1' * | xargs sed -ie 's/string1/string2/g'

Change string1 to string you want to replace.
Change string2 to replace string. 

Delete all files with same extension in Linux command

    find . -name '*.yourext' -print0 | xargs -0 rm

Replace yourext with extension you want.
Or change *.yourext to pattern that you want.