I have a output like below:
A1
B2
C1
D3
A12
B4
A14
I am trying to find A1 by using grep
grep -i "A1"
But I got
A1
A12
A14
So, How can I found only A1? Please suggest.
I have a output like below:
A1
B2
C1
D3
A12
B4
A14
I am trying to find A1 by using grep
grep -i "A1"
But I got
A1
A12
A14
So, How can I found only A1? Please suggest.
could try as..
grep -i 'A1$' inputfile
or
grep -iw 'A1' inputfile
awk '/A1$/' File_Name
(OR)
grep "A1$" File_Name
using 'A1$' is ok for the example in the top post. but it is NOT secure.
e.g.
A1
aA1
bA1
if apply the pattern on the file above, all lines will be printed out.
I think the right solution would be
grep -Fx "A1",
.
example:
kent$ echo "A1
A12
aA1
A1
A1 " | grep -xF "A1"
A1
if A1 is alone on the line you can use
grep "^A1$"
if A1 may be mixed with other data
grep -w "A1"