希望这对于某人来说是一个快速的...我需要在unix中以递归方式查找和替换字符串.
通常,我使用:
perl -e "s/term/differenterm/g;" -pi $(find path/to/DIRECTORY -type f)
Run Code Online (Sandbox Code Playgroud)
但是,我需要替换的字符串包含斜杠,我不知道如何逃避它们?
所以,我需要这样做:
perl -e "s/FIND/REPLACE/g;" -pi $(find path/to/DIRECTORY -type f)
Run Code Online (Sandbox Code Playgroud)
其中FIND ='/ string/path/term'和REPLACE ='/ string/path/newterm'
lui*_*ini 11
你可以使用其他字符/
.例如:
perl -e "s|FIND|REPLACE|g;" -pi $(find path/to/DIRECTORY -type f)
Run Code Online (Sandbox Code Playgroud)
更多信息,请访问http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators