find & replace text in file(s)

find and replace text in a particular file

[code]perl -pi -e ‘s!/replace/this/!/with/this/!g’ file.php[/code]

find and replace text in all files

[code]perl -pi -e ‘s!/replace/this/!/with/this/!g’ *[/code]

backup each file just in case you ruin it!

[code]perl -pi.bak -e ‘s!/replace/this/!/with/this/!g’ *[/code]

Leave a Reply

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