LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   HELP! How to merge two files as column wise?? (https://www.linuxquestions.org/questions/linux-newbie-8/help-how-to-merge-two-files-as-column-wise-4175455322/)

SAAAD 03-23-2013 10:51 PM

HELP! How to merge two files as column wise??
 
Hi,

Would you help me, plz!
I'm really new in Linux, and i am struggling in that 2 days ago
I need to merge 3 files in one file, BUT I want to display them as column!
How I can achieve that?

e.g:
File 1 contains:
1.
2.
3.

File 2 contains:
A
B
C

File 3 contains:
XX
XY
YX

to be in one file looks like this:
File 1 File 2 File 3
1. A XX
2. B XY
3. C YX
and if possible, how to make a header (Title) for each column?

Thanx

SAAAD 03-23-2013 11:34 PM

Tape command is not found in mine!
 
Ive tried Tape command, but its not found in my package!
what other options do we have?

SAAAD 03-24-2013 12:20 AM

over 45!
 
Over 45 had been reviewed my Thread, But no answer yet!

shivaa 03-24-2013 12:30 AM

Simply use:
Code:

~$ paste file1 file2 file3
OR,
~$ paste -d" " file1 file2 file3

Also check manual of paste cmd for additional options here.

SAAAD 03-24-2013 12:32 AM

paste is invalid
 
paste is not valid,
its giving me that its not in the package!

shivaa 03-24-2013 12:36 AM

Command paste is very basic and it should be there.
Code:

~$ which paste
Which OS you're using?

SAAAD 03-24-2013 12:47 AM

Done!
 
It works, I was typing it wrong (past, instead of paste)..
sorry for that.

How about the columns Headings (Title)?

shivaa 03-24-2013 12:53 AM

Just try this:
Code:

~$ echo -e "File1\tFile2\tFile3"; paste file1 file2 file3
OR
~$ echo -e "File1 File2 File3"; paste -d" " file1 file2 file3


SAAAD 03-24-2013 01:28 AM

Awesome!
 
Thanx a lot...

shivaa 03-24-2013 01:31 AM

Please Mark the thread as solved (option is under Thread Tools on top menu), if you think it has so.


All times are GMT -5. The time now is 12:29 PM.