Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print value following a character match

Status
Not open for further replies.

GiovanniC

Technical User
Nov 5, 2001
15
AU
Hi,

I know this is really simple, but its been a while since I've written anything in awk. Basically, I have a file that has the characters "gi=" followed by a number. These strings are in no particular column in the file hence I can't just tell the script to print a particular column. If someone could help me work out a script that finds any occurence of "gi=" and then print out the number that follows, that would be great.

This would be the input (bearing in mind that it could be in a different order elsewhere on the page):

/clone=WHE1132_C07_F14 /gb=CD452818 /gi=31367558

This is the output I'd like to get:

31367558

Thanks for any help.

Giovanni
 
Something like this ?
sed -n '/gi=/s!.*gi=\([0-9]*\).*!\1!p' /path/to/inputfile

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

Many thanks for the suggestion ... got it working.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top