awk - how to merge 2 files in linux -
this question has answer here:
- how can merge 2 files? 4 answers
i have file 1:
line1 line2 line3 .... file 2:
date1 date2 date3 ... and result should be:
line1, date1 line2, date2 line3, date3 ... is there way on linux awk (i think) job on command line? lot
you can use awk
awk 'fnr==nr {a[nr]=$0;next} {print a[fnr]", "$0}' file1 file2 line1, date1 line2, date2 line3, date3 ...., ... fnr==nr {a[nr]=$0;next} when reading first file fil1, store in array a {print a[fnr]", "$0} print out array a using line number index , data file2
Comments
Post a Comment