Unix One Liner to Search and Replace a String in Multiple Files

Below is the unix oneliner to search and replace string in all files with extension .txt:

perl -pi -e "s/<search string >/<replace string >/g" *.txt

Example to search and replace string – “Cold” with “Hot” in all files with extension .txt:

perl -pi -e "s/Cold/Hot/g" *.txt

Leave a Reply

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