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!

Small Mod to Script Help

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
I have the following text:

RXOTX-106-0 B00037A ALL GSM1900 ALPHAA 45
RXOTX-106-1 B00037A ALL GSM1900 ALPHAA 45
RXOTX-106-2 B00037A ALL GSM1900 ALPHAA 45
RXOTX-106-3 B00037A ALL GSM1900 BETAA 45
RXOTX-106-4 B00037B ALL GSM1900 ALPHAB 45
RXOTX-106-5 B00037B ALL GSM1900 ALPHAB 45
RXOTX-106-6 B00037B ALL GSM1900 ALPHAB 45
RXOTX-106-8 B00037C ALL GSM1900 ALPHAC 45
RXOTX-106-9 B00037C ALL GSM1900 ALPHAC 45
RXOTX-106-10 B00037C ALL GSM1900 ALPHAC 45

I have a pre-existing script which will work for me. The only change I want to get completed is instead of field 6 which above is 45, I want field 2 but only the last letter. Everything else will stay the same. So it would only find the last character as in A, B, C. when it replaces below with a[n1[3]]

The script I want to use is:

{
if (FNR==1) {
for (j=1;j<=11;j++) a[j] = 0
fn1 = FILENAME
sub(/[^0-9]*/,&quot;&quot;,fn1)
fn2 = &quot;pre_build_d&quot; fn1
fn1 = &quot;antennas_power_&quot; fn1
print fn1
while ((getline s < fn1) > 0) {
print s
if (s ~ &quot;RXOTX&quot;) {
split(s,f1)
split(f1[1],n1,&quot;-&quot;)
a[n1[3]] = f1[6]
}
}
}
if ($0 ~ &quot;RXOTX&quot;) {
split($0,f1,&quot;,&quot;)
j = split(f1[1],n1,&quot;-&quot;)
print j &quot; &quot; n1[1] &quot; &quot; n1[3] &quot; &quot; a[n1[3]]
if (a[n1[3]]) sub(/SECTOR/,a[n1[3]])
}
print > fn2
}
 
Replace

a[n1[3]] = f1[6]

with

a[n1[3]] = substr(f1[2],length(f1[2]),1) CaKiwi
 
CaKiwi,
I am 100% COMPLETE! Thanks for all the help, you guys were so much help, I can't begin to tell you how much benefit will be received from this program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top