Skip to content

Instantly share code, notes, and snippets.

@cjlyth
Created January 30, 2015 17:19
Show Gist options
  • Save cjlyth/f511100cbc00b775a480 to your computer and use it in GitHub Desktop.
Save cjlyth/f511100cbc00b775a480 to your computer and use it in GitHub Desktop.
sed snippet to replace all regex matches in a string with som eother char
variable="a b a b a x x"
echo $variable
echo $variable | sed -r '/[^[:alnum:]]+/{s/[^[:alnum:]]/_/g}'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment