Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grep for text with wild card in between

Tags:

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?

like image 324
beatbreaker Avatar asked May 06 '11 02:05

beatbreaker


People also ask

How do you grep with wild card?

The wildcard * (asterisk) can be a substitute for any number of letters, numbers, or characters. Note that the asterisk (*) works differently in grep. In grep the asterisk only matches multiples of the preceding character. The wildcard * can be a substitute for any number of letters, numbers, or characters.

Can I use * in grep command?

Search All Files in Directory To search all files in the current directory, use an asterisk instead of a filename at the end of a grep command. The output shows the name of the file with nix and returns the entire line.

How do you grep special characters?

To match a character that is special to grep –E, put a backslash ( \ ) in front of the character. It is usually simpler to use grep –F when you don't need special pattern matching.


1 Answers

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

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

like image 161
sayap Avatar answered Sep 17 '22 21:09

sayap