Skip to content

Instantly share code, notes, and snippets.

@azizshamim
Created May 28, 2013 21:18
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 azizshamim/5666234 to your computer and use it in GitHub Desktop.
Save azizshamim/5666234 to your computer and use it in GitHub Desktop.
awesome regex
fix_hosts() { sed -i -r "/^[^ \t]+[ \t]+(([^ \t]+[ \t]+)+$1([ \t]+[^ \t]+)*|([^ \t]+[ \t]+)*$2([ \t]+[^ \t]+)+)$/ s/^(.*)($1)(.*)$/\1\3/; /^[^ \t]+[ \t]+$ 1[ \t]*$/d" "$2"; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment