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!

Stuck on text replacement AWK 2

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
I have multiple files named like below:

pre_build_out1
pre_build_out2
pre_build_out3

(may have more or less at anytime)

In these above files is the text:

TRU_ZERO
TRU_ONE
TRU_TWO
TRU_THREE
TRU_FOUR
TRU_FIVE
TRU_SIX
TRU_SEVEN
TRU_EIGHT
TRU_NINE
TRU_TEN
TRU_ELEVEN

In the second set of files:

file1
file2
file3

(may have more or less at anytime)

There is the text:

RXOTX-#-# (Example RXOTX-123-0)
RXOTX-#-# (Example RXOTX-123-6)
RXOTX-#-# (Example RXOTX-123-11)

There may be anywhere from 0-11, but no more for the last number.

I need a script to look in the files named file# one by one looking for the text RXOTX and grab the second number, in the case above it would be 0 , 6 , and 11. Take those numbers and replace them in the cooresponding pre_build_out# files.

So using file1, finding RXOTX-123-0, RXOTX-123-6, RXOTX-123-11 the script would go in to the pre_build_out1 and replace TRU_ZERO with 0, TRU_SIX with 6, and TRU_ELEVEN with 11.

The output file should be called pre_build_a_# using the same number as the pre_build_out# file.
 
This assumes that the lines in file* are in numerical order.
Code:
{
  if (FNR==1) {
    fn = FILENAME
    sub(/^[^0-9]*/,"",fn)
    if (NR > 1) {
      close(fn1)
      close(fn2)
    }
    fn1 = "pre_build_out" fn
    fn2 = "pre_build_way_out" fn
#   print fn1
    ix = 0
  }
  split($0,a,"-")
  n = a[3]
  while (ix<n) {
    if ((getline b < fn1) < 1) {
      print &quot;Error&quot;
      exit
    }
    ix++
    print b > fn2
  }
  ix++
  if ((getline b < fn1) < 1) {
    print &quot;Error&quot;
    exit
  }
  print > fn2
}
CaKiwi
 
I do get an error. What do you mean assumes lines in file are in numerical order? I will insert the file# file below then the pre_build file after, so you can see the whole thing.

#--------File1


*** Connected to BH1BSC1 ***
<RXTCP:MO=RXOTG-11;


RADIO X-CEIVER ADMINISTRATION
TG TO CHANNEL GROUP CONNECTION DATA

MO CELL CHGR
RXOTG-11 B00227A 0
B00227B 0
B00227C 0
B00227A 1
B00227B 1
B00227C 1

END

<RXCDP:MO=RXOTG-11;

RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT CONFIGURATION DATA

MO RESULT ARFCN MISMATCH
RXORX-11-0 CONFIG HOP NONE
RXORX-11-1 CONFIG HOP NONE
RXORX-11-2 CONFIG HOP NONE
RXORX-11-4 CONFIG HOP NONE
RXORX-11-5 CONFIG HOP NONE
RXORX-11-6 CONFIG HOP NONE
RXORX-11-8 CONFIG HOP NONE
RXORX-11-10 CONFIG HOP NONE

MO RESULT ARFCN TXAD TN BPC CHCOMB OFFS XRA ICM
RXOTS-11-0-0 CONFIG 638 2 7 1268 TCH 0 NO ON
RXOTS-11-0-1 CONFIG 638 2 6 1359 TCH 0 NO ON
RXOTS-11-0-2 CONFIG 638 2 5 1334 TCH 0 NO ON
RXOTS-11-0-3 CONFIG 638 2 4 1314 TCH 0 NO ON
RXOTS-11-0-4 CONFIG 638 2 3 1388 TCH 0 NO ON
RXOTS-11-0-5 CONFIG 638 2 2 1402 TCH 0 NO ON
RXOTS-11-0-6 CONFIG HOP 5 1 1443 TCH 0 NO ON
RXOTS-11-0-7 CONFIG HOP 5 0 1446 TCH 0 NO ON
RXOTS-11-1-0 CONFIG HOP 5 7 1398 TCH 0 NO ON
RXOTS-11-1-1 CONFIG HOP 5 6 1406 TCH 0 NO ON
RXOTS-11-1-2 CONFIG HOP 5 5 1365 TCH 0 NO ON
RXOTS-11-1-3 CONFIG HOP 5 4 1389 TCH 0 NO ON
RXOTS-11-1-4 CONFIG HOP 5 3 1419 TCH 0 NO ON
RXOTS-11-1-5 CONFIG HOP 5 2 1438 TCH 0 NO ON
RXOTS-11-1-6 CONFIG HOP 6 1 1337 TCH 0 NO ON
RXOTS-11-1-7 CONFIG HOP 6 0 1445 TCH 0 NO ON
RXOTS-11-2-0 CONFIG 638 2 0 1471 BCCH 0 NO ON
RXOTS-11-2-1 CONFIG 638 2 1 1465 SDCCH8 0 NO ON
RXOTS-11-2-2 CONFIG HOP 6 7 1423 TCH 0 NO ON
RXOTS-11-2-3 CONFIG HOP 6 6 1412 TCH 0 NO ON
RXOTS-11-2-4 CONFIG HOP 6 5 1401 TCH 0 NO ON
RXOTS-11-2-5 CONFIG HOP 6 4 1449 TCH 0 NO ON
RXOTS-11-2-6 CONFIG HOP 6 3 1444 TCH 0 NO ON
RXOTS-11-2-7 CONFIG HOP 6 2 1394 TCH 0 NO ON
RXOTS-11-4-0 CONFIG HOP 3 7 4404 TCH 3 NO ON
RXOTS-11-4-1 CONFIG HOP 3 6 4367 TCH 3 NO ON
RXOTS-11-4-2 CONFIG HOP 3 5 4384 TCH 3 NO ON
RXOTS-11-4-3 CONFIG HOP 3 4 4387 TCH 3 NO ON
RXOTS-11-4-4 CONFIG HOP 3 3 4378 TCH 3 NO ON
RXOTS-11-4-5 CONFIG HOP 3 2 4390 TCH 3 NO ON
RXOTS-11-4-6 CONFIG HOP 3 1 4394 TCH 3 NO ON
RXOTS-11-4-7 CONFIG HOP 3 0 4401 TCH 3 NO ON
RXOTS-11-5-0 CONFIG HOP 4 7 4354 TCH 3 NO ON
RXOTS-11-5-1 CONFIG HOP 4 6 4385 TCH 3 NO ON
RXOTS-11-5-2 CONFIG HOP 4 5 4380 TCH 3 NO ON
RXOTS-11-5-3 CONFIG HOP 4 4 4389 TCH 3 NO ON
RXOTS-11-5-4 CONFIG HOP 4 3 4373 TCH 3 NO ON
RXOTS-11-5-5 CONFIG HOP 4 2 4392 TCH 3 NO ON
RXOTS-11-5-6 CONFIG HOP 4 1 4398 TCH 3 NO ON
RXOTS-11-5-7 CONFIG HOP 4 0 4402 TCH 3 NO ON
RXOTS-11-6-0 CONFIG 629 1 0 4473 BCCH 3 NO ON
RXOTS-11-6-1 CONFIG 629 1 1 4475 SDCCH8 3 NO ON
RXOTS-11-6-2 CONFIG 629 1 7 4417 TCH 3 NO ON
RXOTS-11-6-3 CONFIG 629 1 6 4416 TCH 3 NO ON
RXOTS-11-6-4 CONFIG 629 1 5 4413 TCH 3 NO ON
RXOTS-11-6-5 CONFIG 629 1 4 4408 TCH 3 NO ON
RXOTS-11-6-6 CONFIG 629 1 3 4414 TCH 3 NO ON
RXOTS-11-6-7 CONFIG 629 1 2 4412 TCH 3 NO ON
RXOTS-11-8-0 CONFIG HOP 7 7 1252 TCH 6 NO ON
RXOTS-11-8-1 CONFIG HOP 7 6 1251 TCH 6 NO ON
RXOTS-11-8-2 CONFIG HOP 7 5 1250 TCH 6 NO ON
RXOTS-11-8-3 CONFIG HOP 7 4 1216 TCH 6 NO ON
RXOTS-11-8-4 CONFIG HOP 7 3 1196 TCH 6 NO ON
RXOTS-11-8-5 CONFIG HOP 7 2 1206 TCH 6 NO ON
RXOTS-11-8-6 CONFIG HOP 7 1 1245 TCH 6 NO ON
RXOTS-11-8-7 CONFIG HOP 7 0 1241 TCH 6 NO ON
RXOTS-11-10-0 CONFIG 617 0 0 1463 BCCH 6 NO ON
RXOTS-11-10-1 CONFIG 617 0 1 1462 SDCCH8 6 NO ON
RXOTS-11-10-2 CONFIG 617 0 7 1461 TCH 6 NO ON
RXOTS-11-10-3 CONFIG 617 0 6 1455 TCH 6 NO ON
RXOTS-11-10-4 CONFIG 617 0 5 1454 TCH 6 NO ON
RXOTS-11-10-5 CONFIG 617 0 4 1450 TCH 6 NO ON
RXOTS-11-10-6 CONFIG 617 0 3 1442 TCH 6 NO ON
RXOTS-11-10-7 CONFIG 617 0 2 1432 TCH 6 NO ON

MO RESULT ARFCN TXAD BSPWR C0F MISMATCH
RXOTX-11-0 CONFIG 638 2 45 YES NONE
RXOTX-11-1 CONFIG HOP 5 45 NO NONE
RXOTX-11-2 CONFIG HOP 6 45 NO NONE
RXOTX-11-4 CONFIG HOP 3 45 NO NONE
RXOTX-11-5 CONFIG HOP 4 45 NO NONE
RXOTX-11-6 CONFIG 629 1 45 YES NONE
RXOTX-11-8 CONFIG HOP 7 45 NO NONE
RXOTX-11-10 CONFIG 617 0 45 YES NONE

CONFIGURATION DATA MAY BE INCONSISTENT

END

<RXAPP:MO=RXOTG-11;


RADIO X-CEIVER ADMINISTRATION
ABIS PATH STATUS

MO
RXOTG-11

DEV DCP APUSAGE APSTATE TEI
RBLT24-264 1 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-265 2 CONC TRXC SIGNALLING 5 6 8 10
RBLT24-266 3 UNDEF IDLE
RBLT24-267 4 UNDEF IDLE
RBLT24-268 5 UNDEF IDLE
RBLT24-269 6 UNDEF IDLE
RBLT24-270 7 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX32 IDLE
RBLT24-271 8 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-272 9 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-273 10 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-274 11 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-275 12 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-276 13 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-277 14 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-278 15 UNDEF IDLE
RBLT24-279 16 UNDEF IDLE
RBLT24-280 17 UNDEF IDLE
RBLT24-281 18 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-282 19 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-283 20 CONC CF AND TRXC SIGNALLING 62 0 1 2 4
RBLT24-284 21 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-285 22 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-286 23 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
RBLT24-287 24 MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA
MPLEX16 SPEECH/DATA

END

<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

END


*** Connected to BH1BSC1 ***
<RXMOP:MO=RXORX-11-0;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO RXD BAND ANTA ANTB
RXORX-11-0 AB GSM1900 ALPHAA BETAA

END

<RXMOP:MO=RXORX-11-1;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO RXD BAND ANTA ANTB
RXORX-11-1 AB GSM1900 ALPHAA BETAA

END

<RXMOP:MO=RXORX-11-2;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO RXD BAND ANTA ANTB
RXORX-11-2 AB GSM1900 ALPHAA BETAA

END

<RXMOP:MO=RXORX-11-4;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO RXD BAND ANTA ANTB
RXORX-11-4 AB GSM1900 ALPHAB BETAB

END

<RXMOP:MO=RXORX-11-5;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO RXD BAND ANTA ANTB
RXORX-11-5 AB GSM1900 ALPHAB BETAB

END

<RXMOP:MO=RXORX-11-6;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO RXD BAND ANTA ANTB
RXORX-11-6 AB GSM1900 ALPHAC BETAC

END

<RXMOP:MO=RXORX-11-8;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO RXD BAND ANTA ANTB
RXORX-11-8 AB GSM1900 ALPHAC BETAC

END

<RXMOP:MO=RXORX-11-10;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO RXD BAND ANTA ANTB
RXORX-11-10 AB GSM1900 ALPHAC BETAC

END

<RXMOP:MO=RXOTX-11-0;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO CELL CHGR BAND ANT MPWR
RXOTX-11-0 B00227A ALL GSM1900 BETAA 45

END

<RXMOP:MO=RXOTX-11-1;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO CELL CHGR BAND ANT MPWR
RXOTX-11-1 B00227A ALL GSM1900 BETAA 45

END

<RXMOP:MO=RXOTX-11-2;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO CELL CHGR BAND ANT MPWR
RXOTX-11-2 B00227A ALL GSM1900 BETAA 45

END

<RXMOP:MO=RXOTX-11-4;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO CELL CHGR BAND ANT MPWR
RXOTX-11-4 B00227B ALL GSM1900 BETAB 45

END

<RXMOP:MO=RXOTX-11-5;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO CELL CHGR BAND ANT MPWR
RXOTX-11-5 B00227B ALL GSM1900 BETAB 45

END

<RXMOP:MO=RXOTX-11-6;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO CELL CHGR BAND ANT MPWR
RXOTX-11-6 B00227B ALL GSM1900 BETAB 45

END

<RXMOP:MO=RXOTX-11-8;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO CELL CHGR BAND ANT MPWR
RXOTX-11-8 B00227C ALL GSM1900 BETAC 45

END

<RXMOP:MO=RXOTX-11-10;


RADIO X-CEIVER ADMINISTRATION
MANAGED OBJECT DATA

MO CELL CHGR BAND ANT MPWR
RXOTX-11-10 B00227C ALL GSM1900 BETAC 45

END




#----pre_build_out1

RXMOI:MO=RXOTG-121,COMB=HYB,RSITE=SITE_NUMBER,SWVER=B0531R0702;
RXESI:MO=RXOTG-121;
RXBLE:MO=RXOTG-121;
RXMOI:MO=RXOCF-121,TEI=TG_TEI;
RXMOC:MO=RXOCF-121,SIG=CONC;
RXMOI:MO=RXOIS-121;
RXMOI:MO=RXOTF-121,TFMODE=SA;
RXMOI:MO=RXOCON-121,DCP=64&&87;
DTBLE:DIP=T1_NUMBER;
EXDAI:DEV=DEVICE_RANGE;
BLODE:DEV=DEVICE_RANGE;
RXAPI:MO=RXOTG-121,DEV=DEVICE_RANGE,DCP=T1_DCPS;

RXMOI:MO=RXOTRX-121-TRU_ZERO,TEI=0,DCP1=128,DCP2=129&130;
RXMOI:MO=RXOTRX-121-TRU_ONE,TEI=1,DCP1=131,DCP2=132&133;
RXMOI:MO=RXOTRX-121-TRU_TWO,TEI=2,DCP1=134,DCP2=135&136;
RXMOI:MO=RXOTRX-121-TRU_THREE,TEI=3,DCP1=137,DCP2=138&139;
RXMOI:MO=RXOTRX-121-TRU_FOUR,TEI=4,DCP1=140,DCP2=141&142;
RXMOI:MO=RXOTRX-121-TRU_FIVE,TEI=5,DCP1=143,DCP2=144&145;
RXMOI:MO=RXOTRX-121-TRU_SIX,TEI=6,DCP1=160,DCP2=161&162;
RXMOI:MO=RXOTRX-121-TRU_SEVEN,TEI=7,DCP1=163,DCP2=164&165;
RXMOI:MO=RXOTRX-121-TRU_EIGHT,TEI=8,DCP1=166,DCP2=167&168;
RXMOI:MO=RXOTRX-121-TRU_NINE,TEI=9,DCP1=169,DCP2=170&171;
RXMOI:MO=RXOTRX-121-TRU_TEN,TEI=10,DCP1=172,DCP2=173&174;
RXMOI:MO=RXOTRX-121-TRU_ELEVEN,TEI=11,DCP1=175,DCP2=176&177;

RXMOC:MO=RXOTRX-121-TRU_ZERO,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_ONE,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_TWO,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_THREE,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_FOUR,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_FIVE,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_SIX,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_SEVEN,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_EIGHT,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_NINE,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_TEN,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_ELEVEN,SIG=CONC;

RXMOI:MO=RXOTX-121-TRU_ZERO,BAND=GSM1900,MPWR=POWER,ANT=ZERO_ALPHA;
RXMOI:MO=RXOTX-121-TRU_ONE,BAND=GSM1900,MPWR=POWER,ANT=ONE_ALPHA;
RXMOI:MO=RXOTX-121-TRU_TWO,BAND=GSM1900,MPWR=POWER,ANT=TWO_ALPHA;
RXMOI:MO=RXOTX-121-TRU_THREE,BAND=GSM1900,MPWR=POWER,ANT=THREE_ALPHA;
RXMOI:MO=RXOTX-121-TRU_FOUR,BAND=GSM1900,MPWR=POWER,ANT=FOUR_ALPHA;
RXMOI:MO=RXOTX-121-TRU_FIVE,BAND=GSM1900,MPWR=POWER,ANT=FIVE_ALPHA;
RXMOI:MO=RXOTX-121-TRU_SIX,BAND=GSM1900,MPWR=POWER,ANT=SIX_ALPHA;
RXMOI:MO=RXOTX-121-TRU_SEVEN,BAND=GSM1900,MPWR=POWER,ANT=SEVEN_ALPHA;
RXMOI:MO=RXOTX-121-TRU_EIGHT,BAND=GSM1900,MPWR=POWER,ANT=EIGHT_ALPHA;
RXMOI:MO=RXOTX-121-TRU_NINE,BAND=GSM1900,MPWR=POWER,ANT=NINE_ALPHA;
RXMOI:MO=RXOTX-121-TRU_TEN,BAND=GSM1900,MPWR=POWER,ANT=TEN_ALPHA;
RXMOI:MO=RXOTX-121-TRU_ELEVEN,BAND=GSM1900,MPWR=POWER,ANT=ELEVEN_ALPHA;

RXMOI:MO=RXORX-121-TRU_ZERO,RXD=AB,BAND=GSM1900,ANTA=ZERO_ALPHA,ANTB=ZERO_BETA;
RXMOI:MO=RXORX-121-TRU_ONE,RXD=AB,BAND=GSM1900,ANTA=ONE_ALPHA,ANTB=ONE_BETA;
RXMOI:MO=RXORX-121-TRU_TWO,RXD=AB,BAND=GSM1900,ANTA=TWO_ALPHA,ANTB=TWO_BETA;
RXMOI:MO=RXORX-121-TRU_THREE,RXD=AB,BAND=GSM1900,ANTA=THREE_ALPHA,ANTB=THREE_BETA;
RXMOI:MO=RXORX-121-TRU_FOUR,RXD=AB,BAND=GSM1900,ANTA=FOUR_ALPHA,ANTB=FOUR_BETA;
RXMOI:MO=RXORX-121-TRU_FIVE,RXD=AB,BAND=GSM1900,ANTA=FIVE_ALPHA,ANTB=FIVE_BETA;
RXMOI:MO=RXORX-121-TRU_SIX,RXD=AB,BAND=GSM1900,ANTA=SIX_ALPHA,ANTB=SIX_BETA;
RXMOI:MO=RXORX-121-TRU_SEVEN,RXD=AB,BAND=GSM1900,ANTA=SEVEN_ALPHA,ANTB=SEVEN_BETA;
RXMOI:MO=RXORX-121-TRU_EIGHT,RXD=AB,BAND=GSM1900,ANTA=EIGHT_ALPHA,ANTB=EIGHT_BETA;
RXMOI:MO=RXORX-121-TRU_NINE,RXD=AB,BAND=GSM1900,ANTA=NINE_ALPHA,ANTB=NINE_BETA;
RXMOI:MO=RXORX-121-TRU_TEN,RXD=AB,BAND=GSM1900,ANTA=TEN_ALPHA,ANTB=TEN_BETA;
RXMOI:MO=RXORX-121-TRU_ELEVEN,RXD=AB,BAND=GSM1900,ANTA=ELEVEN_ALPHA,ANTB=ELEVEN_BETA;

RXMOI:MO=RXOTS-121-TRU_ZERO-0&&-7;
RXMOI:MO=RXOTS-121-TRU_ONE-0&&-7;
RXMOI:MO=RXOTS-121-TRU_TWO-0&&-7;
RXMOI:MO=RXOTS-121-TRU_THREE-0&&-7;
RXMOI:MO=RXOTS-121-TRU_FOUR-0&&-7;
RXMOI:MO=RXOTS-121-TRU_FIVE-0&&-7;
RXMOI:MO=RXOTS-121-TRU_SIX-0&&-7;
RXMOI:MO=RXOTS-121-TRU_SEVEN-0&&-7;
RXMOI:MO=RXOTS-121-TRU_EIGHT-0&&-7;
RXMOI:MO=RXOTS-121-TRU_NINE-0&&-7;
RXMOI:MO=RXOTS-121-TRU_TEN-0&&-7;
RXMOI:MO=RXOTS-121-TRU_ELEVEN-0&&-7;
 
Sorry, I totally misread your problem. try this
Code:
{
  fn = FILENAME
  sub(/^[^0-9]*/,&quot;&quot;,fn)
  fn1 = &quot;pre_build_out&quot; fn
  fn2 = &quot;pre_build_a&quot; fn
  for (j=0;j<11;j++) b[j] = 0
  do {
    if ($0 ~ /^RXOTX/) {
      split($1,a,&quot;-&quot;)
      n = a[3]
      print n
      b[n] = 1
    }
  } while (getline > 0)

  while ((getline < fn1) > 0) {
    if ($0 ~ /TRU_/) {
      if (b[0]) sub(/TRU_ZERO/,&quot;0&quot;,$0)
      if (b[1]) sub(/TRU_ONE/,&quot;1&quot;,$0)
      if (b[2]) sub(/TRU_TWO/,&quot;2&quot;,$0)
      if (b[3]) sub(/TRU_THREE/,&quot;3&quot;,$0)
      if (b[4]) sub(/TRU_FOUR/,&quot;4&quot;,$0)
      if (b[5]) sub(/TRU_FIVE/,&quot;5&quot;,$0)
      if (b[6]) sub(/TRU_SIX/,&quot;6&quot;,$0)
      if (b[7]) sub(/TRU_SEVEN/,&quot;7&quot;,$0)
      if (b[8]) sub(/TRU_EIGHT/,&quot;8&quot;,$0)
      if (b[9]) sub(/TRU_NINE/,&quot;9&quot;,$0)
      if (b[10]) sub(/TRU_TEN/,&quot;10&quot;,$0)
      if (b[11]) sub(/TRU_ELEVEN/,&quot;11&quot;,$0)
    }
    print > fn2
  }
}
CaKiwi
 
CaKiwi,
I ran it just like above and it is not working. It is only creating one file, (At this time I am expecting three) and it is not changing any text.

Any ideas?
 
Sorry again,I was in a hurry and I only tested it using 1 file.
Code:
{
  do {
    fn = FILENAME
    sub(/^[^0-9]*/,&quot;&quot;,fn)
    fn1 = &quot;pre_build_out&quot; fn
    fn2 = &quot;pre_build_a&quot; fn
    for (j=0;j<11;j++) b[j] = 0
    do {
      if ($0 ~ /^RXOTX/) {
        split($1,a,&quot;-&quot;)
        n = a[3]
        b[n] = 1
      }
    } while (getline > 0 && FNR > 1)

    while ((getline < fn1) > 0) {
      if ($0 ~ /TRU_/) {
        if (b[0]) sub(/TRU_ZERO/,&quot;0&quot;)
        if (b[1]) sub(/TRU_ONE/,&quot;1&quot;)
        if (b[2]) sub(/TRU_TWO/,&quot;2&quot;)
        if (b[3]) sub(/TRU_THREE/,&quot;3&quot;)
        if (b[4]) sub(/TRU_FOUR/,&quot;4&quot;)
        if (b[5]) sub(/TRU_FIVE/,&quot;5&quot;)
        if (b[6]) sub(/TRU_SIX/,&quot;6&quot;)
        if (b[7]) sub(/TRU_SEVEN/,&quot;7&quot;)
        if (b[8]) sub(/TRU_EIGHT/,&quot;8&quot;)
        if (b[9]) sub(/TRU_NINE/,&quot;9&quot;)
        if (b[10]) sub(/TRU_TEN/,&quot;10&quot;)
        if (b[11]) sub(/TRU_ELEVEN/,&quot;11&quot;)
      }
      print > fn2
    }
  } while (FNR == 1)
}
Run it by entering

nawk -f this-file file* CaKiwi
 
CaKiwi,
It is creating the correct number of files, but still not changing anything. Oh, yea....email me your addy and I will send that beer through the post!

Example of the file it is not changing:

RXMOI:MO=RXOTRX-121-TRU_ZERO,TEI=0,DCP1=128,DCP2=129&130;
RXMOI:MO=RXOTRX-121-TRU_ONE,TEI=1,DCP1=131,DCP2=132&133;
RXMOI:MO=RXOTRX-121-TRU_TWO,TEI=2,DCP1=134,DCP2=135&136;
RXMOI:MO=RXOTRX-121-TRU_THREE,TEI=3,DCP1=137,DCP2=138&139;
RXMOI:MO=RXOTRX-121-TRU_FOUR,TEI=4,DCP1=140,DCP2=141&142;
RXMOI:MO=RXOTRX-121-TRU_FIVE,TEI=5,DCP1=143,DCP2=144&145;
RXMOI:MO=RXOTRX-121-TRU_SIX,TEI=6,DCP1=160,DCP2=161&162;
RXMOI:MO=RXOTRX-121-TRU_SEVEN,TEI=7,DCP1=163,DCP2=164&165;
RXMOI:MO=RXOTRX-121-TRU_EIGHT,TEI=8,DCP1=166,DCP2=167&168;
RXMOI:MO=RXOTRX-121-TRU_NINE,TEI=9,DCP1=169,DCP2=170&171;
RXMOI:MO=RXOTRX-121-TRU_TEN,TEI=10,DCP1=172,DCP2=173&174;
RXMOI:MO=RXOTRX-121-TRU_ELEVEN,TEI=11,DCP1=175,DCP2=176&177;
 
This is what I got

RXMOI:MO=RXOTRX-121-0,TEI=0,DCP1=128,DCP2=129&130;
RXMOI:MO=RXOTRX-121-1,TEI=1,DCP1=131,DCP2=132&133;
RXMOI:MO=RXOTRX-121-2,TEI=2,DCP1=134,DCP2=135&136;
RXMOI:MO=RXOTRX-121-TRU_THREE,TEI=3,DCP1=137,DCP2=138&139;
RXMOI:MO=RXOTRX-121-4,TEI=4,DCP1=140,DCP2=141&142;
RXMOI:MO=RXOTRX-121-5,TEI=5,DCP1=143,DCP2=144&145;
RXMOI:MO=RXOTRX-121-6,TEI=6,DCP1=160,DCP2=161&162;
RXMOI:MO=RXOTRX-121-TRU_SEVEN,TEI=7,DCP1=163,DCP2=164&165;
RXMOI:MO=RXOTRX-121-8,TEI=8,DCP1=166,DCP2=167&168;
RXMOI:MO=RXOTRX-121-TRU_NINE,TEI=9,DCP1=169,DCP2=170&171;
RXMOI:MO=RXOTRX-121-10,TEI=10,DCP1=172,DCP2=173&174;
RXMOI:MO=RXOTRX-121-TRU_ELEVEN,TEI=11,DCP1=175,DCP2=176&177;

Put some print statements in the loops to see where it is going. CaKiwi
 
It could be the line

if ($0 ~ /^RXOTX/) {

Take out the ^ if the line in file* does not start in column 1. CaKiwi
 
No that was not it. Do you think we have to close the files? If so, How? Also can you tell me exactly where to &quot;Put some print statements in the loops to see where it is going.&quot;

Beaster
 
put a print statement after the statement

n = a[3]
print n &quot; &quot; $0

It should also have close statements in case you have a large number of files, but this is not causing the current problem.

....
}
close(fn1)
close(fn2)
} while (FNR == 1) CaKiwi
 
Still not coming out, do you think it has anything to do with that I am on Solaris? I am sure we will get it, but I hate taking up your time CaKiwi......With the print n statement I did not see anything.
 
put a
print $1

before and after

if ($0 ~ /RXOTX/) {

put a
print a[1] &quot; &quot; a[2] &quot; &quot; a[3]

after the split()
CaKiwi
 
This is what I did, does it look right?

{
do {
fn = FILENAME
sub(/^[^0-9]*/,&quot;&quot;,fn)
fn1 = &quot;pre_build_out&quot; fn
fn2 = &quot;pre_build_a&quot; fn
for (j=0;j<11;j++) b[j] = 0
do {
print $1
if ($0 ~ /^RXOTX/) {
print $1
split($1,a,&quot;-&quot;)
print a[1] &quot; &quot; a[2] &quot; &quot; a[3]
n = a[3]
print n &quot; &quot; $0
b[n] = 1
}
} while (getline > 0 && FNR > 1)

while ((getline < fn1) > 0) {
if ($0 ~ /TRU_/) {
if (b[0]) sub(/TRU_ZERO/,&quot;0&quot;)
if (b[1]) sub(/TRU_ONE/,&quot;1&quot;)
if (b[2]) sub(/TRU_TWO/,&quot;2&quot;)
if (b[3]) sub(/TRU_THREE/,&quot;3&quot;)
if (b[4]) sub(/TRU_FOUR/,&quot;4&quot;)
if (b[5]) sub(/TRU_FIVE/,&quot;5&quot;)
if (b[6]) sub(/TRU_SIX/,&quot;6&quot;)
if (b[7]) sub(/TRU_SEVEN/,&quot;7&quot;)
if (b[8]) sub(/TRU_EIGHT/,&quot;8&quot;)
if (b[9]) sub(/TRU_NINE/,&quot;9&quot;)
if (b[10]) sub(/TRU_TEN/,&quot;10&quot;)
if (b[11]) sub(/TRU_ELEVEN/,&quot;11&quot;)
}
print > fn2
}
close(fn1)
close(fn2)
} while (FNR == 1)
}
 
Oh, I see! It is only doing the first file, but it is creating 3 files but not changing any of the text! Aha! It is a long printout, so I did not list it here. Tell me if you want to see it. It is basically the exact same text that is in pre_build_out1. The file sizes are staying the same as well.
 
Wait, you didn't remove the ^ from

if ($0 ~ /RXOTX/) {
CaKiwi
 
I changed it and took out the ^, and the result is below. It looks like it did it three times: It is long....

RXMOI:MO=RXOTX-121-TRU_ZERO,BAND=GSM1900,MPWR=POWER,ANT=ZERO_ALPHA;
RXMOI:MO=RXOTX-121-TRU_ZERO,BAND=GSM1900,MPWR=POWER,ANT=ZERO_ALPHA;
RXMOI:MO=RXOTX 121 TRU_ZERO,BAND=GSM1900,MPWR=POWER,ANT=ZERO_ALPHA;
 
I'm back. Let's review what I did. I cut and pasted the data you posted into file1 and pre_build_out1. I copied file1 as file2 and pre_build_out1 as pre_build_out2. I ran the following awk script:

{
do {
fn = FILENAME
print fn
sub(/^[^0-9]*/,&quot;&quot;,fn)
print fn
fn1 = &quot;pre_build_out&quot; fn
fn2 = &quot;pre_build_a&quot; fn
for (j=0;j<12;j++) b[j] = 0
do {
if ($0 ~ /RXOTX/) {
# print $1
split($1,a,&quot;-&quot;)
sub(/;$/,&quot;&quot;,a[3])
# print &quot;--> &quot; a[1] &quot; &quot; a[2] &quot; &quot; a[3]
n = a[3]
# print &quot;--> &quot; n
b[n] = 1
}
} while (getline > 0 && FNR > 1)

for (j in b) print &quot;j = &quot; j
for (j=0;j<12;j++) print &quot;b[&quot; j &quot;]=&quot; b[j]

while ((getline < fn1) > 0) {
if ($0 ~ /TRU_/) {
if (b[0]) sub(/TRU_ZERO/,&quot;0&quot;)
if (b[1]) sub(/TRU_ONE/,&quot;1&quot;)
if (b[2]) sub(/TRU_TWO/,&quot;2&quot;)
if (b[3]) sub(/TRU_THREE/,&quot;3&quot;)
if (b[4]) sub(/TRU_FOUR/,&quot;4&quot;)
if (b[5]) sub(/TRU_FIVE/,&quot;5&quot;)
if (b[6]) sub(/TRU_SIX/,&quot;6&quot;)
if (b[7]) sub(/TRU_SEVEN/,&quot;7&quot;)
if (b[8]) sub(/TRU_EIGHT/,&quot;8&quot;)
if (b[9]) sub(/TRU_NINE/,&quot;9&quot;)
if (b[10]) sub(/TRU_TEN/,&quot;10&quot;)
if (b[11]) sub(/TRU_ELEVEN/,&quot;11&quot;)
}
print > fn2
}
close(fn1)
close(fn2)
} while (FNR == 1)
}

I got the following debug output on the screen:

file1
1
j = 11
j = 10
j = 9
j = 8
j = 7
j = 6
j = 5
j = 4
j = 3
j = 2
j = 1
j = 0
b[0]=1
b[1]=1
b[2]=1
b[3]=0
b[4]=1
b[5]=1
b[6]=1
b[7]=0
b[8]=1
b[9]=0
b[10]=1
b[11]=0
file2
2
j = 11
j = 10
j = 9
j = 8
j = 7
j = 6
j = 5
j = 4
j = 3
j = 2
j = 1
j = 0
b[0]=1
b[1]=1
b[2]=1
b[3]=0
b[4]=1
b[5]=1
b[6]=1
b[7]=0
b[8]=1
b[9]=0
b[10]=1
b[11]=0

and the files pre_build_a1 and pre_build_a2 start with the following data:

RXMOI:MO=RXOTG-121,COMB=HYB,RSITE=SITE_NUMBER,SWVER=B0531R0702;
RXESI:MO=RXOTG-121;
RXBLE:MO=RXOTG-121;
RXMOI:MO=RXOCF-121,TEI=TG_TEI;
RXMOC:MO=RXOCF-121,SIG=CONC;
RXMOI:MO=RXOIS-121;
RXMOI:MO=RXOTF-121,TFMODE=SA;
RXMOI:MO=RXOCON-121,DCP=64&&87;
DTBLE:DIP=T1_NUMBER;
EXDAI:DEV=DEVICE_RANGE;
BLODE:DEV=DEVICE_RANGE;
RXAPI:MO=RXOTG-121,DEV=DEVICE_RANGE,DCP=T1_DCPS;

RXMOI:MO=RXOTRX-121-0,TEI=0,DCP1=128,DCP2=129&130;
RXMOI:MO=RXOTRX-121-1,TEI=1,DCP1=131,DCP2=132&133;
RXMOI:MO=RXOTRX-121-2,TEI=2,DCP1=134,DCP2=135&136;
RXMOI:MO=RXOTRX-121-TRU_THREE,TEI=3,DCP1=137,DCP2=138&139;
RXMOI:MO=RXOTRX-121-4,TEI=4,DCP1=140,DCP2=141&142;
RXMOI:MO=RXOTRX-121-5,TEI=5,DCP1=143,DCP2=144&145;
RXMOI:MO=RXOTRX-121-6,TEI=6,DCP1=160,DCP2=161&162;
RXMOI:MO=RXOTRX-121-TRU_SEVEN,TEI=7,DCP1=163,DCP2=164&165;
RXMOI:MO=RXOTRX-121-8,TEI=8,DCP1=166,DCP2=167&168;
RXMOI:MO=RXOTRX-121-TRU_NINE,TEI=9,DCP1=169,DCP2=170&171;
RXMOI:MO=RXOTRX-121-10,TEI=10,DCP1=172,DCP2=173&174;
RXMOI:MO=RXOTRX-121-TRU_ELEVEN,TEI=11,DCP1=175,DCP2=176&177;

RXMOC:MO=RXOTRX-121-0,SIG=CONC;
RXMOC:MO=RXOTRX-121-1,SIG=CONC;
RXMOC:MO=RXOTRX-121-2,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_THREE,SIG=CONC;
RXMOC:MO=RXOTRX-121-4,SIG=CONC;
RXMOC:MO=RXOTRX-121-5,SIG=CONC;
RXMOC:MO=RXOTRX-121-6,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_SEVEN,SIG=CONC;
RXMOC:MO=RXOTRX-121-8,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_NINE,SIG=CONC;
RXMOC:MO=RXOTRX-121-10,SIG=CONC;
RXMOC:MO=RXOTRX-121-TRU_ELEVEN,SIG=CONC;

What happens if you do the same? CaKiwi
 
I ran it exactly like your script above to the tee. I got the output below. My three files all were created pre_build_a1, a2, and a3. But all three now have -121 in them like below. They are all the same, when each should be different. Is the script processing each file# file individually? Because they are all different numbers like my first post. So what I get is: from debug:

bham_mta@wepmas1> nawk -f nawk_test pre_build_out*
pre_build_out1
1
j = 2
j = 3
j = 4
j = 5
j = TRU_SEVEN,BAND=GSM1900,MPWR=POWER,ANT=SEVEN_ALPHA
j = 6
j = 7
j = 8
j = 9
j = TRU_THREE,BAND=GSM1900,MPWR=POWER,ANT=THREE_ALPHA
j = TRU_TWO,BAND=GSM1900,MPWR=POWER,ANT=TWO_ALPHA
j = TRU_FIVE,BAND=GSM1900,MPWR=POWER,ANT=FIVE_ALPHA
j = 10
j = 11
j = TRU_ONE,BAND=GSM1900,MPWR=POWER,ANT=ONE_ALPHA
j = TRU_ZERO,BAND=GSM1900,MPWR=POWER,ANT=ZERO_ALPHA
j = TRU_NINE,BAND=GSM1900,MPWR=POWER,ANT=NINE_ALPHA
j = TRU_SIX,BAND=GSM1900,MPWR=POWER,ANT=SIX_ALPHA
j = TRU_FOUR,BAND=GSM1900,MPWR=POWER,ANT=FOUR_ALPHA
j = TRU_ELEVEN,BAND=GSM1900,MPWR=POWER,ANT=ELEVEN_ALPHA
j = TRU_EIGHT,BAND=GSM1900,MPWR=POWER,ANT=EIGHT_ALPHA
j = TRU_TEN,BAND=GSM1900,MPWR=POWER,ANT=TEN_ALPHA
j = 0
j = 1
b[0]=0
b[1]=0
b[2]=0
b[3]=0
b[4]=0
b[5]=0
b[6]=0
b[7]=0
b[8]=0
b[9]=0
b[10]=0
b[11]=0
pre_build_out2
2
j = 2
j = 3
j = 4
j = 5
j = TRU_SEVEN,BAND=GSM1900,MPWR=POWER,ANT=SEVEN_ALPHA
j = 6
j = 7
j = 8
j = 9
j = TRU_THREE,BAND=GSM1900,MPWR=POWER,ANT=THREE_ALPHA
j = TRU_TWO,BAND=GSM1900,MPWR=POWER,ANT=TWO_ALPHA
j = TRU_FIVE,BAND=GSM1900,MPWR=POWER,ANT=FIVE_ALPHA
j = 10
j = 11
j = TRU_ONE,BAND=GSM1900,MPWR=POWER,ANT=ONE_ALPHA
j = TRU_ZERO,BAND=GSM1900,MPWR=POWER,ANT=ZERO_ALPHA
j = TRU_NINE,BAND=GSM1900,MPWR=POWER,ANT=NINE_ALPHA
j = TRU_SIX,BAND=GSM1900,MPWR=POWER,ANT=SIX_ALPHA
j = TRU_FOUR,BAND=GSM1900,MPWR=POWER,ANT=FOUR_ALPHA
j = TRU_ELEVEN,BAND=GSM1900,MPWR=POWER,ANT=ELEVEN_ALPHA
j = TRU_EIGHT,BAND=GSM1900,MPWR=POWER,ANT=EIGHT_ALPHA
j = TRU_TEN,BAND=GSM1900,MPWR=POWER,ANT=TEN_ALPHA
j = 0
j = 1
b[0]=0
b[1]=0
b[2]=0
b[3]=0
b[4]=0
b[5]=0
b[6]=0
b[7]=0
b[8]=0
b[9]=0
b[10]=0
b[11]=0
pre_build_out3
3
j = 2
j = 3
j = 4
j = 5
j = TRU_SEVEN,BAND=GSM1900,MPWR=POWER,ANT=SEVEN_ALPHA
j = 6
j = 7
j = 8
j = 9
j = TRU_THREE,BAND=GSM1900,MPWR=POWER,ANT=THREE_ALPHA
j = TRU_TWO,BAND=GSM1900,MPWR=POWER,ANT=TWO_ALPHA
j = TRU_FIVE,BAND=GSM1900,MPWR=POWER,ANT=FIVE_ALPHA
j = 10
j = 11
j = TRU_ONE,BAND=GSM1900,MPWR=POWER,ANT=ONE_ALPHA
j = TRU_ZERO,BAND=GSM1900,MPWR=POWER,ANT=ZERO_ALPHA
j = TRU_NINE,BAND=GSM1900,MPWR=POWER,ANT=NINE_ALPHA
j = TRU_SIX,BAND=GSM1900,MPWR=POWER,ANT=SIX_ALPHA
j = TRU_FOUR,BAND=GSM1900,MPWR=POWER,ANT=FOUR_ALPHA
j = TRU_ELEVEN,BAND=GSM1900,MPWR=POWER,ANT=ELEVEN_ALPHA
j = TRU_EIGHT,BAND=GSM1900,MPWR=POWER,ANT=EIGHT_ALPHA
j = TRU_TEN,BAND=GSM1900,MPWR=POWER,ANT=TEN_ALPHA
j = 0
j = 1
b[0]=0
b[1]=0
b[2]=0
b[3]=0
b[4]=0
b[5]=0
b[6]=0
b[7]=0
b[8]=0
b[9]=0
b[10]=0
b[11]=0
And in the files pre_build_a1, 2 and 3 the data is the same when it should be different. Can I email you the three files?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top