Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.