Unix Shell - Re: How to search for string and assign the value on next line to

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > November 2005 > Re: How to search for string and assign the value on next line to





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: How to search for string and assign the value on next line to
Ed Morton

2005-11-23, 5:54 pm



jonhardt@yahoo.com wrote:

> Here's kind of a goofy one...haven't figured out how (if) it is doable
> by sed/awk yet, so I thought I'd give the brain trust here a looksee
> and determine if there is a better way to handle this issue...
>
> I have several large txt files that I need to search for a particular
> string and assign the value on a subsequent line to a variable...so for
> instance using this snippet:
>
>
> ---=[ OS Version (Version.Release.Modification.Fix)
> ]=--------------------
> 5.3.0.0
>
>
> I want to be able to search the file for the string
> "Version.Release.Modification.Fix"
>
> and assign the variable OS_VER a value of 5.3.0.0
>
> Thanks for any/all replies!
>


OS_VER=`awk 'f{print;exit}/Version\.Release\.Modification\.Fix/{f=1}' file`

Regards,

Ed.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com