Search and replace with Perl in command line
Search and Replace in one or multiple files
Single file:
perl -pi -e 's/%SEARCHED_VALUE%/%REPLACE_VALUE%/g' file
Multiple files:
files | xargs -I[] perl -pi -e 's/%SEARCHED_VALUE%/%REPLACE_VALUE%/g' []
example:
```bash
ls *.txt | xargs -I[] perl -pi -e 's/%SEARCHED_VALUE%/%REPLACE_VALUE%/g' []
Search and Replace in files and directories names
rename 's/%SEARCHED_VALUE%/%REPLACE_VALUE%/' files
Written by padawin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Perl
Authors
janosgyerik
25.11K
Jean-Remy Duboc
12.22K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#