Skip to content

Instantly share code, notes, and snippets.

@ChicagoDev
Created March 6, 2015 19:58
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 ChicagoDev/b5332d47a2b970a312ca to your computer and use it in GitHub Desktop.
Save ChicagoDev/b5332d47a2b970a312ca to your computer and use it in GitHub Desktop.
Formatting parentheses in Sed
# needs to be executed with the expanded REGEX synatax -E flag
# sed -Ef script.sed parenthesesFile.txt
s/ *\(/ \(/g;
s/\) */\) /g;
s/\(\)/\( \)/g;
s/\(\(/\( \(/g;
s/\)\)/\) \)/g;
s/\(([a-zA-Z0-9])/( \1/g;
s/([a-zA-Z0-9])\(/\1 (/g;
s/\( +\)/\( \)/g;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment