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!

HELP USING AWK 1

Status
Not open for further replies.

johngiggs

Technical User
Oct 30, 2002
492
US
I am trying to get the slot address and volume tag and put them in separate columns. Below are the commands that I'm trying to use in order to accomplish this.

cat file | egrep 'Slot Address|Volume Tag' > test.out
cat test.out | awk '{print $3,$4}'| sed 's/.....................//g' | awk 'BEGIN{FS="\n";OFS="\t";}{print $1,$2}'

Sample output from the file:

Slot Address 4110
Volume Tag ..................... HN5037L1
Slot Address 4111
Volume Tag ..................... B00006L1
Slot Address 4112
Volume Tag .....................

I want the final output to appear as follows:

Slot Volume
====================
4110 HN5037
4111 B00006

How should I go about doing this?

Thanks,

John
 
Try

awk -f jg.awk file

# ------ jg.awk ------

BEGIN {OFS = "\t";print "Slot Volume";print "===================="}
/Slot Address/{a = $3}
/Volume Tag/{if (NF==4) print a, $4} CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Thanks, CaKiwi!! That works great!!

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top