Skip to content

Instantly share code, notes, and snippets.

@MatthewHannigan
Last active August 29, 2015 14:07
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 MatthewHannigan/fca0ca0f80b91234f17a to your computer and use it in GitHub Desktop.
Save MatthewHannigan/fca0ca0f80b91234f17a to your computer and use it in GitHub Desktop.
bash expands {c,h} before the command sees it
$ echo fish >a.c
$ grep -r --include=\*.{c,h} fish .
./a.c:fish
$ grep -r --include=\*.{c,h} fish .
./a.c:fish
grep doesn't like {c,h}
$ grep -r --include="*.{c,h}" fish .
$ grep -r --include="*.[ch]" fish .
./a.c:fish
and look at number of args - 6 v 5
$ echo grep -r --include=\*.{c,h} fish . | wc
1 6 43
$ echo grep -r --include="*.{c,h}" fish . | wc
1 5 33
$ echo grep -r --include="*.{c,h}" fish .
grep -r --include=*.{c,h} fish .
$ echo grep -r --include=\*.{c,h} fish .
grep -r --include=*.c --include=*.h fish .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment