Perl Pie Giveaway (Perl one-liner examples)

Perl Pie Giveaway (Perl one-liner examples)

Last updated:
  • replace all occurrences of string "foo" (no quotes) with string "bar" (no quotes) on all php files in the current directory

    $ perl -pi -e s/foo/bar *.php
    
  • example with lots of Unix-style paths (using "|" as delimiter so we don't need to escape the slashes)

    $ perl -pi -e 's|foo/bar|/var/www/foo/bar/baz/qux|' *.php