awk and grep using two files

I have two file one will have WWN and port details and another file will have allies name. I need to check what allies name was given to each wwn and create a consolidate report which will both port details, allies name.

file one switchshow

 133    1   21   188500   id    N4         Online      FC  F-Port  10:00:00:00:c9:67:51:4b
 134    1   22   188600   id    N4         Online      FC  F-Port  10:00:00:90:fa:0c:aa:e7

File two alishow

cat alishow |grep -B1 10:00:00:00:c9:67:51:4b |grep alias
alias: hostname_01

I need output like this

133    1   21   188500   id    N4         Online      FC  F-Port  10:00:00:00:c9:67:51:4b; alias: hostname_01

Hi, try:

awk 'FNR == NR && $10 ~ /([0-9a-f]+:){7}[0-9a-f]+/ {A[$10]=P};FNR == NR {P=$0;next};$10 ~ /([0-9a-f]+:){7}[0-9a-f]+/ {$10=$10 ";" A[$10]}1' alishow switchshow

Regards.

Its not that easy to guess your second input file's structure; your cat | grep | grep doesn't really help. Nevertheless, try also

awk 'FNR == NR {match ($0, /[A-Fa-f0-9:]+/); A[substr ($0, RSTART, RLENGTH)] = LAST; LAST = $0; next} $NF in A {print $0 ";", A[$NF]}' file2 file1
 133    1   21   188500   id    N4         Online      FC  F-Port  10:00:00:00:c9:67:51:4b; alias: hostname_01

Hi RudiC I am getting output like this if i use your command

 128    1   16   188000   id    N8         Online      FC  F-Port  50:00:09:74:08:1b:b9:c8 ;            50:00:09:74:08:1a:91:c8
 129    1   17   188100   id    N8         Online      FC  F-Port  50:00:09:74:08:1b:b9:cc ;            50:00:09:74:08:1a:91:cc

I need one line before it will have the alias name for that wwn. Is there any way i can use for loop.

First awk only the WWN from file switchshow and save in one file 111
second use the for loop to check one by one WWN using

|grep -B1 "WWN" |grep alias

and save the out as 222

and add the 222 out as priffx to the switchshow file

Please post small but representative samples of your input files, using code tags NOT PHP tags.

---------- Post updated at 15:19 ---------- Previous update was at 15:18 ----------

AND an output sample.