Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    If $1 is -r then grep will treat it as an option, and hence you are effectively calling grep with a filename but with no pattern argument, I think Commented Jan 23, 2016 at 0:45
  • @steeldriver Oh..how can i pass -r to grep without it treating it as an option ? Commented Jan 23, 2016 at 0:48
  • At least with GNU grep, you can indicate the end of option arguments using -- i.e. grep -q -- "$1" "$f" Commented Jan 23, 2016 at 0:49