Skip to content

Instantly share code, notes, and snippets.

@bsnux
Created November 21, 2022 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsnux/6db4f4e6d605d96dcf1c66f9ed185ad2 to your computer and use it in GitHub Desktop.
Save bsnux/6db4f4e6d605d96dcf1c66f9ed185ad2 to your computer and use it in GitHub Desktop.
Perl one-liners
# Starting REPL
perl -del
# Search and replace in place
perl -p -i -e "s/test/testing/g" /tmp/testing.txt
# Search/replace in specific files in a directory
perl -p -i -e 's/oldstring/newstring/g' `find ./ -name *.html`
# Similar to awk
ls -l | perl -lane 'print $F[2]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment