I have the following information in the text file:
1:boot
2:book
3:booze
4:machine
5:boots
6:bungie
7:bark
8:aardvark
9:broken$tuff
10:robots
11:rebine
when i did a grep -n "b*" a_file.txt, it returned
1:boot
2:book
3:booze
4:machine
5:boots
6:bungie
7:bark
8:aardvark
9:broken$tuff
10:robots
11:rebine
I thought it would match the letter b followed by anything. But why is line 4,8,10,11 appearing since its not starting with letter B? I actually quite confused how to correctly use the * wildcard.
I have made a search online, and found that, if i wanted to search for anything that starts with the letter b, i should instead do a grep -n "^b" a_file.txt.
Anyone can explain to me what grep -n "b*" a_file.txt does? as in, "b*". I can't understand how it is matched.
Many thanks.