Reputation: 7961
fgrep -ircl --include=*.{sql} "[--]" *
doesn't seem to be doing the trick. Please help...
Thanks for the responses guys. I am trying to replace the '--' with '#' and am having a tough time. I created a new question here. If you could help, that had be awesome.
Upvotes: 3
Views: 832
Reputation: 879691
If you want to fgrep all files that end with .sql
then use
fgrep -ircl --include=*.sql -- -- *
or (note the comma in {sql,}
:
fgrep -ircl --include=*.{sql,} -- -- *
If you want to fgrep more than one type of extension, then use something like
fgrep -ircl --include=*.{sql,txt} -- -- *
As others have already mentioned, the first --
tells fgrep to stop looking for flags and options. The second --
is the fixed-string pattern.
Upvotes: 1
Reputation: 18538
Try using single quotes '[--]'
instead of "[--]"
fgrep -ircl --include=*.{sql} '[--]' *
Upvotes: 0
Reputation: 239301
You need to escape dash characters inside square brackets, which are used to represent ranges inside a character class ([a-z]
for example). In this case, however, you don't need to use square brackets to match a literal string.
Finally, --
is a speical sequence that causes argument parsing to stop. To include a literal --
as an argument, you'll have to explicitly stop argument parsing:
fgrep -ircl --include=*.{sql} -- -- *
Upvotes: 1
Reputation: 3655
Dash characters can only be in the first position in brackets [] because they indicate a range [a-z] or [0-9]. You could do [-][-].
Upvotes: 1
Reputation: 24445
That looks like a regular expression character class matching the (single) -
character. The string --
is commonly used to indicate "no more parameters follow", so perhaps you should try
fgrep -ircl --include=*.{sql} -- -- *
that is "end of parameters" followed by the actual string you want to search for.
Upvotes: 4