linux - how to Aggregate files or merge -
can 1 merge defferent files common data (columns)? please =(
file1.txt id kg year 3454 1000 2010 3454 1200 2011 3323 1150 2009 2332 1000 2011 3454 1156 201 file2.txt id place 3454 a1 3323 a2 2332 a6 5555 a9 file 1+2 id kg year place 3454 1000 2010 a1 3454 1200 2011 a1 3323 1150 2009 a2 2332 1000 2011 a6 3454 1156 2013 a1
so second file should connected first. can see id 5555 file 2 not using.
how in linux or....
if don't care maintaining order of lines, use karakfa's join
command.
to keep original order of lines, use awk
awk ' nr==fnr {place[$1]=$2; next} $1 in place {print $0, place[$1]} ' file2.txt file1.txt | column -t
id kg year place 3454 1000 2010 a1 3454 1200 2011 a1 3323 1150 2009 a2 2332 1000 2011 a6 3454 1156 201 a1
Comments
Post a Comment