replace text in a file with perl Steve Stonebraker July 3, 2011 here’s how to replace text in a file with perl: perl -pi -e 's~OLDTEXT~NEWTEXT~g' /path/to/filename Tags: file search and replace text, perl pie replace text, perl replace text, perl text replace, replace text file perl, replace text one line