1825719 Members
2828 Online
109686 Solutions
New Discussion

exact match

 
SOLVED
Go to solution
Pando
Regular Advisor

exact match

i have a data inside a file that looks like this:

...
Difusion Lot ID, 11111-11 (line 1)
Lot ID, 3649 (line 2)
...

I need to get only the value of the 2nd line and stored in a variable but
what i get was the value of the 1st line because of the word Lot ID.

I have used the command:

measbatch=$(awk -F "," '/Lot ID/ {print $2}' $MFILE)

Maximum points for all correct answers!
2 REPLIES 2
john korterman
Honored Contributor
Solution

Re: exact match

Hi Fernando,
if you are absolutely sure that the second line starts with Lot ID, you can use the "hat" symbol for specifying beginning of line, e.g.:
measbatch=$(awk -F "," '/^Lot ID/ {print $2}' $MFILE)

but perhaps you can define the line requested line differently?

regards,
John K.
it would be nice if you always got a second chance
Pando
Regular Advisor

Re: exact match

Many thanks!