4 ms·
I use it for in-place search and replace within files. perl -pi -e 's/change this/into this/g' filename(s) -p assumes an input loop around your script. Lines
by drivers99 2y ago
I use it for in-place search and replace within files.
perl -pi -e 's/change this/into this/g' filename(s)
-p assumes an input loop around your script. Lines are printed.
-i in-place editing of files
-e may be used to enter a single line of script. Multiple -e commands may be given to build up a multiline script.
Combined with "find" with -exec and/or pipe the filenames into xargs and you can do a global search and replace across a whole tree of files.
- emmelaich 2y agoYep, but for that example, sed has a -i too. Also I recommend adding a backup for inplace edits. man perlrun recommends -spi.orig