grep for text with wild card in between

55,828

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

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

Share:
55,828

Related videos on Youtube

beatbreaker
Author by

beatbreaker

Updated on July 09, 2022

Comments

  • beatbreaker
    beatbreaker almost 2 years

    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?

    • pavium
      pavium about 13 years
      so, the '==> *.sh <==' is all in the file? You need to use a regular expression.
  • Tony Delroy
    Tony Delroy about 13 years
    (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.)
  • Sergey Telshevsky
    Sergey Telshevsky about 11 years
    @TonyD great comment but use backquotes to delimit code or terminology so readers won't have to think was the double quote/quote a part of the command or not