Hopefully, this will be a quick one for someone here… I need to find and replace a string recursively in unix.
Normally, I use:
perl -e "s/term/differenterm/g;" -pi $(find path/to/DIRECTORY -type f)
But, the string I need to replace contains slashes, and I’m not sure how to escape them?
So, I need to do:
perl -e "s/FIND/REPLACE/g;" -pi $(find path/to/DIRECTORY -type f)
where FIND = ‘/string/path/term’
and REPLACE = ‘/string/path/newterm’
You could use other characters besides
/. For example:More info in http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators