I have two files.
file1:
Dave 734.838.9800
Bob 313.123.4567
Carol 248.344.5576
Mary 313.449.1390
Ted 248.496.2204
Alice 616.556.4458
file2:
Bob Tuesday
Carol Monday
Ted Sunday
Alice Wednesday
Dave Thursday
Mary Saturday
I want to merge these two into file3.
file3 should look like:
Name On-Call Phone
Carol MONDAY 248.344.5576
Bob TUESDAY 313.123.4567
Alice WEDNESDAY 616.556.4458
Dave THURSDAY 734.838.9800
Nobody FRIDAY 634.296.3356
Mary SATURDAY 313.449.1390
Ted SUNDAY 248.496.2204
So how can i do this in a shell script?
awk 'BEGIN {printf("%s %10s %10s \n" ,"Name", "On-Call", "Phone")} FNR==NR{a[$1]=$2 FS $3;next}{ print $0, a[$1]}' file1.txt file2.txt | column -t