awk - add the names to file1 based on file2 -


i have 2 files file1 , file2. of names in file2 not in file1. add names in file1.

file1

anna         14/2   =   7.0 alex         23/6   =   3.8 deffy        27/3   =   9.0 hobert       24/9   =   2.7 

file2

anna alex benny cathar deffy hobbert sam 

my desired output shown below.

anna         14/2   =   7.0 alex         23/6   =   3.8 benny        0/0    =   0 cathar       0/0    =   0  deffy        27/3   =   9.0 hobert       24/9   =   2.7 sam          0/0    =   0 

your appreciated!

kent$  awk 'nr==fnr{a[$1]=$0;next}a[$0]{print a[$0];next}{print $1,"0/0 = 0"} ' f1 f2|column -t anna     14/2  =  7.0 alex     23/6  =  3.8 benny    0/0   =  0 cathar   0/0   =  0 deffy    27/3  =  9.0 hobbert  0/0   =  0 sam      0/0   =  0 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -