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!

How to read Second field in awk

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
In my file file# there is text RXOCF, in the field accross from this text, there is a two digit number. Like 60 or 62. I need to grab that number and find the text TG_TEI in the first pre_build_b# file and replace it, but keep using the end number to the output file pre_build_c#

Here is what I have so far that create the new file, but it grabs the whole original file# file, I just need that text next to RXOCF, the example is below:

The file file#:

<RXMOP:MO=RXOCF-11;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO TEI SWVERREPL SWVERACT SIG
RXOCF-11 62 DEFAULT B0531R0702 CONC

BSSWANTED NEGSTATUS
90 SUCCESSFUL

My Script:

/RXOCF/ {
fn = FILENAME
sub(/^[^0-9]*/,&quot;&quot;,fn)
fn1 = &quot;file&quot; fn
fn2 = &quot;pre_build_c&quot; fn
num = $2
while ((getline < fn1 ) > 0) {
gsub(/TG_TEI/,num)
print > fn2
}
close(fn1)
close(fn2)
}
 
Has anyone been able to review this for me??
 
I already worked it out, my resolution was to add the TEI value to the input master_sorted file and just read it in the beginning! It works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top