perl -p -i.bak -e 's/search_str/replace_str/g' filename
What do -p
, -i.bak
s/
and /g
mean?
-p
: assume 'while (<>) { ... }
'
loop around program and print each
processed line too.-i.bak
: change the input file
(filename
) inplace and create the
file filename.bak
as backup.s in s/
: to mark substitutiong
- make the substitution
globally..that is don't stop after
first replacement.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With