Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kurtroberts
Created December 19, 2018 15:17
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 kurtroberts/7ce4644f1060c1eb72e7eb870cc772dc to your computer and use it in GitHub Desktop.
Save kurtroberts/7ce4644f1060c1eb72e7eb870cc772dc to your computer and use it in GitHub Desktop.
Silly Perl Tricks
# remove a string from all lines in a file
cat thing-groups.csv | perl -ne 's/,SmartGroup//g; print $_' -
# just the ones with that smartgroup, but remove it
cat thing-groups.csv | perl -ne 'while(/(.*),SmartGroup(.*)/g){ print "$1$2\n" };' -
# just the ones with that smartgroup, but make it the last one
cat thing-groups.csv | perl -ne 'while(/(.*)(,SmartGroup)(.*)/g){ print "$1$3$2\n" };' -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment