@ShanxT, That's exactly the same command the op said he has already tried.
I can't say why it's not pasting correctly for him (dos line-endings, perhaps?), because for me all the lines from file1 and file2 combine as expected. However, it doesn't give exactly the desired output anyway, as each column is separated by
only a semicolon, without any space padding.
To get the above formatting, it seems to me that the best solution is to use awk's getline function to read from the second file.
Code:
awk '{ getline f2line < "file2.txt" ; print $0 " ; " f2line }' file1.txt
http://www.gnu.org/software/gawk/man...e/Getline.html
You could also use a two-step process; one command to add a semicolon to the end of each line first, and then a second to combine the lines in the two files.
Fortunately, you can combine both steps into one line using
process substitution. This gives me the above output:
Code:
paste -d " " <( sed 's/$/ ;/' file1.txt ) file2.txt
I used -d " " because
paste outputs tabs by default. You can change it if desired, of course.
http://mywiki.wooledge.org/ProcessSubstitution
By the way, please use regular
[code][/code] tags, and not php code tags. 1) That isn't php, obviously, and 2) for some reason php boxes don't honor the column width limit, meaning long lines will force side-scrolling.