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!

New Awk Script Help 3

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
I know very little, so please if you can help, make it as easy as possible for me to understand. I am getting better though thanks to everyone's help!

Here goes!

I have several files named file1, file2, file3, etc.

I would like to use nawk, and output the files to different
files named block_obj_1, block_obj_2, block_obj_3, and so on using the original file #
I do have a temp directory to send them to.

The internal file looks similiar to the below, but have different numbers in each file:

RXOTS-11-0-0 CONFIG 638 2 7 7481 TCH
RXOTS-11-0-1 CONFIG 638 2 6 7488 TCH
RXOTS-11-0-2 CONFIG 638 2 5 7503 TCH
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 629 1 45 YES NONE
RXORX-11-0 CONFIG HOP NONE
RXORX-11-1 CONFIG HOP NONE
RXORX-11-2 CONFIG HOP NONE
MO CELL CHGR
RXOTG-11 B00227A 0
B00227B 0
B00227C 0
B00227A 1
B00227B 1
B00227C 1
RXOTG-11

DEV DCP APUSAGE APSTATE TEI
RBLT24-264 1 UNDEF IDLE
RBLT24-265 2 UNDEF IDLE




I need to grep on the first field for RXOTS, RXOTX, and RXORX (In that order).

So it would only find:

RXOTS-11-0-0
RXOTS-11-0-1
RXOTS-11-0-2
RXOTX-11-0
RXOTX-11-1
RXOTX-11-2
RXOTX-11-4
RXORX-11-0
RXORX-11-1
RXORX-11-2

Then for every RXOTX it found it would create text below it like:
RXOTRX-11-0
RXOTRX-11-1
RXOTRX-11-2
RXOTRX-11-4 Basically it would just create a new line of text adding an R to it for each TX found.

So then my output would be:
RXOTS-11-0-0
RXOTS-11-0-1
RXOTS-11-0-2
RXOTX-11-0
RXOTX-11-1
RXOTX-11-2
RXOTX-11-4
RXORX-11-0
RXORX-11-1
RXORX-11-2
RXOTRX-11-0
RXOTRX-11-1
RXOTRX-11-2
RXOTRX-11-4

Below the TRX portion, I need the following added using the first number only (EXAMPLE BELOW):

RXOCON-11
RXODP-11
RXOIS-11
RXOTF-11
RXOCF-11
RXOTG-11

I want to end up with text similiar to below:

RXOTS-11-0-0
RXOTS-11-0-1
RXOTS-11-0-2
RXOTX-11-0
RXOTX-11-1
RXOTX-11-2
RXOTX-11-4
RXORX-11-0
RXORX-11-1
RXORX-11-2
RXOTRX-11-0
RXOTRX-11-1
RXOTRX-11-2
RXOTRX-11-4
RXOCON-11
RXODP-11
RXOIS-11
RXOTF-11
RXOCF-11
RXOTG-11

The first and second number will be different in each file1, file2 and so on. The only thing
uniq is RXOTS, RXOTX, RXORX.

I know this is alot, and is similiar to a former post, but it is different, I promise!

Thanks as always!

Beaster
 
Thanks for the kind words. I'll have a pint tonight and pretend you paid for it. CaKiwi
 
CaKiwi
I went to run this today and realized one issue with this. If there is a nummber with three digits, it will not print them all when setting up the TRX down. See my example of the output:
rxbli:mo=RXOTRX-296-9,force;
rxbli:mo=RXOTRX-296-10,force;
rxbli:mo=RXOCON-29,force;
rxbli:mo=RXODP-29,force;
rxbli:mo=RXOIS-29,force;
rxbli:mo=RXOTF-29,force;
rxbli:mo=RXOCF-29,force;
rxbli:mo=RXOTG-29,force;


It only printed 29 instead of 296. There will only be 3 digits max in the numeric field. I changed:

b = substr(a[0],7,2)

to

b = substr(a[0],7,3)

It printed correctly, but screwed up the digits above that only have two, so I changed it back. Can you help?
 
change
b = substr(a[0],7,2)

TO

split(a[0], arr, "-");
b=arr[2]; vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
vlad,
Thanks it worked great with the change!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top