I have a file with following text as below
classA = Something
classB = AB1234567
classC = Something more
classD = Something Else
Objective:
Using a shell script, I want to read the text which says AB1234567
from above complete text.
So to start, I can read the second line of the above text using following logic in my shell script:
secondLine=`sed -n '2p' my_file`;
echo $secondLine;
secondLine
outputs classB = AB1234567
. How do I extract AB1234567
from classB = AB1234567
in my shell script?
Question:
Considering the fact that AB
is common in that particular part of the text all the files I deal with, how can I make sed
to read all the numbers after AB
?
Please note that classB = AB1234567
could end with a space or a newline. And I need to get this into a variable