I am trying to write a script to do the following.
Go thru the file until it finds an expression ("9227493"). Once this expression is found, I want the script to search in a reverse fashion until it finds another string ("hopid"). And I want to save that line.
How would I go about doing this?
My file looks like this:
First Line
Second Line
third line hop 2746
fourth line
fifth line
sixth line
seventh Line 9227493abc
eighth Line
nineth line hop 8888
tenth line
eleventh line 9227493abc
twelvth line
The output will be:
2746
8888
Thank you in advance for your assistance.
Kalpesh
Go thru the file until it finds an expression ("9227493"). Once this expression is found, I want the script to search in a reverse fashion until it finds another string ("hopid"). And I want to save that line.
How would I go about doing this?
My file looks like this:
First Line
Second Line
third line hop 2746
fourth line
fifth line
sixth line
seventh Line 9227493abc
eighth Line
nineth line hop 8888
tenth line
eleventh line 9227493abc
twelvth line
The output will be:
2746
8888
Thank you in advance for your assistance.
Kalpesh
Comment