23

I would like to grep something like ==> *.sh <==. But it doesn't work, I can grep everything up to .sh <== but not get the wild card to work.

What's the trick here?

jww
  • 97,681
  • 90
  • 411
  • 885
beatbreaker
  • 349
  • 2
  • 5
  • 9

1 Answers1

37

You need to grep for something like "==> .*\.sh <=="

The .* part matches any character for any length, the \. part matches a dot.

sayap
  • 6,169
  • 2
  • 36
  • 40
  • 4
    (By way of explanation, "*.sh" is a filename glob pattern, which is a completely different notation for matching than the regular expressions expected by grep. In regular expressions, * means 0 or more repetitions of the previous expression, which in your case was a space. A dot means any character at all. So, " *.sh" could match " Xsh" but never "file.sh". Google regular expresions for details / examples etc.) – Tony Delroy May 06 '11 at 04:12
  • 2
    @TonyD great comment but use `backquote`s to delimit code or terminology so readers won't have to think was the double quote/quote a part of the command or not – Sergey Telshevsky Mar 22 '13 at 13:27