3 ms·
I only use it as an alternative to a stream of awk/grep/sed/... Usually much more concise, readable and faster.
by emmelaich 3y ago
I only use it as an alternative to a stream of awk/grep/sed/...
Usually much more concise, readable and faster.
- drivers99 3y agoI 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 3y agoYep, but for that example, sed has a -i too. Also I recommend adding a backup for inplace edits. man perlrun recommends -spi.orig