3

I am trying to grep lines where the first character is an A, B, or C.

I am trying this:

grep -i "^[a-c]*" data.txt

I want it to only care about the very first character, the rest of the line I don't care about.

AJJ
  • 852
  • 2
  • 12
  • 21

1 Answers1

8

Because you have used the * (zero or more) quantifier, your expression is going to match every line. Change it to

grep -i "^[a-c]" data.txt

and it should work as you intend.

steeldriver
  • 131,985
  • 21
  • 239
  • 326
  • 2
    @ArukaJ https://askubuntu.com/questions/714503/regular-expressions-vs-filename-globbing – muru Oct 13 '17 at 02:20