Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created January 11, 2014 21:06
Show Gist options
  • Select an option

  • Save coderofsalvation/8376782 to your computer and use it in GitHub Desktop.

Select an option

Save coderofsalvation/8376782 to your computer and use it in GitHub Desktop.
greps on keywords (keyword1 AND keyword2 AND ..)
# greps on keywords (keyword1 AND keyword2 AND ..)
# @param string keyword
# usage: printf "foo bar\nbar foo\n" | multimatch foo bar
multigrep() {
awk 'BEGIN{for(i=1;i<ARGC;i++) a[i]=ARGV[i]; ARGC=1} {for (i in a) if ($0 !~ a[i]) next; print}' "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment