file1.txt :
india pakistan bangladesh
japan canada africa
USA srilanka Nepal
file2.txt
Delhi
Tokyo
washington
I have to cut the first column of file1.txt and apend it with file2.txt as another column like this
Delhi india
Tokyo japan
washington USA
Anyone one please say me the syntax for the above .
aigles
April 22, 2008, 8:51am
2
A possible way :
awk '{print $1}' file1.txt | paste -d' ' file2.txt -
awk can replaced by cut :
cut -d' ' -f1 file1.txt | paste -d' ' file2.txt -
Jean-Pierre.
in a single command
awk 'BEGIN{ while ( getline < "secondfile" ) { arr[i++]=$0 } }{ print arr[j++], $1 }' firstfile
sakthifire:
file1.txt :
india pakistan bangladesh
japan canada africa
USA srilanka Nepal
file2.txt
Delhi
Tokyo
washington
I have to cut the first column of file1.txt and apend it with file2.txt as another column like this
Delhi india
Tokyo japan
washington USA
Anyone one please say me the syntax for the above .
Just Use Simple Cmd :
First Cut fhe first field of first file
$ cut -d' ' -f1 <first filename> > tmpfirst
$ cut -d' ' -f2 <second filename> > tmpsecond
$ paste tmpfirst tmpsecond > newfile
(-f1 means first field , -f2 means second field)