In bash,
grep -r --exclude={*.c,} 'HELLO' // exclude c files grep -r --include={*.c,} 'HELLO' // just same with grep -r 'HELLO'
What’s the problem?
Advertisement
Answer
You are using curly braces incorrectly. The correct syntax would look like
grep -r --include='*.c' 'HELLO' .
(Notice also the addition of the missing file name argument .
at the end.)
You can see what’s going wrong by putting an echo
in front and examining what the shell expands the braces to.
$ echo grep -r --exclude={*.c,} 'HELLO' grep -r --exclude=*.c --exclude= HELLO