Berkeley CSUA MOTD:Entry 44961
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/04/04 [General] UID:1000 Activity:popular
4/4     

2006/10/25-27 [Computer/SW/Languages/Perl] UID:44961 Activity:nil
10/25   I recall there being a really quick easy perl way to do global
        replace from the command line, but I can't seem to quite get it
        right.  Something like:
        perl -e 's/pattern/replace/' file.txt
        Help?
        \_ I know how to do it with sed:
           sed -e s/pattern/replace/g file.txt > /tmp/output.txt
           \_ modern seds support perl's -i syntax as shown below:
              sed -i -e s/pattern/replace/g file.txt
        \_ perl -pi -e 's/pattern/replace/' file.txt
           (You need the -pi)