Skip to content

Instantly share code, notes, and snippets.

@jmervine
Created February 3, 2014 17:46
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 jmervine/8788669 to your computer and use it in GitHub Desktop.
Save jmervine/8788669 to your computer and use it in GitHub Desktop.
Strip specials in BASH
# replaces numbers, commas, periods, asterisks, slashes (forward and back), all brackets and parentheses
#
# note: I'd like to get this working with less '-e' calls but it wasn't for me on
#
# $ sed --version
# GNU sed version 4.2.1
sed -r -e 's/[0-2,\.\*\\\/]/_/g' -e 's/\[/_/g' -e 's/\]/_/g' -e 's/\{/_/g' -e 's/\}/_/g' -e 's/\(/_/g' -e 's/\)/_/g' -e 's/_{2,}/_/g' -e 's/_$//'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment