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]*/,"",fn1)
fn2 = "pre_build_d" fn1
fn1 = "antennas_power_" fn1
print fn1
while ((getline s < fn1) > 0) {
print s
if (s ~ "RXOTX" {
split(s,f1)
split(f1[1],n1,"-"
a[n1[3]] = f1[6]
}
}
}
if ($0 ~ "RXOTX" {
split($0,f1,","
j = split(f1[1],n1,"-"
print j " " n1[1] " " n1[3] " " a[n1[3]]
if (a[n1[3]]) sub(/SECTOR/,a[n1[3]])
}
print > fn2
}
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]*/,"",fn1)
fn2 = "pre_build_d" fn1
fn1 = "antennas_power_" fn1
print fn1
while ((getline s < fn1) > 0) {
print s
if (s ~ "RXOTX" {
split(s,f1)
split(f1[1],n1,"-"
a[n1[3]] = f1[6]
}
}
}
if ($0 ~ "RXOTX" {
split($0,f1,","
j = split(f1[1],n1,"-"
print j " " n1[1] " " n1[3] " " a[n1[3]]
if (a[n1[3]]) sub(/SECTOR/,a[n1[3]])
}
print > fn2
}