Quote:
|
Originally Posted by hunter85
Hi Experts,
I have a problem. Can you Help me?
I need a UNIX shell script for the below logic using AWK. The logic must lay on by vaildating the first field.I am using -KSH.
I am in real hurry. :  Your help will be highly appreciated.
Table 1:
Cricket 16 28
Tennis 26 15
Wrestling 12 34
Table 2:
Cricket 25 26
***** 16 13
Wrestling 11 22
I need output as in table3.
Table 3:
Cricket 16 28 25 26
***** NA NA 16 13
Tennis 26 15 NA NA
Wrestling 12 34 11 22
If any questions plz ask me. Thankyou for your consideration.
|
awk ' FILENAME==ARGV[1] { a[$1]=$2" "$3 }
FILENAME==ARGV[2] { if(a[$1]=="") {a[$1]="NA NA "$2" "$3 } else { a[$1]=a[$1]" "$2" "$3 } }
END { for(i in a) print i" "a[i]}' Table11 Table2 | sort |
awk '{ if(NF<4) { print $0" NA NA"} else { print $0 }}' > Table3
now Table3 will contain .... wt u want.......
Cricket 16 28 25 26
***** NA NA 16 13
Tennis 26 15 NA NA
Wrestling 12 34 11 22
Enjoyyyyyyyyyyyyyyyyyyy