LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   writing the content of two files to a single file horizontally (https://www.linuxquestions.org/questions/linux-newbie-8/writing-the-content-of-two-files-to-a-single-file-horizontally-868718/)

dinakumar12 03-15-2011 09:49 AM

writing the content of two files to a single file horizontally
 
Hi all,

assume that i am having two files file.1 and file.2

these are the contents of file.1

Dinesh
Ganesh
Anish
Dev
Jagan
Gopi

these are the contents of file.2

admin
engineer
ceo
doctor
press
operation

i want these two contents to be written in another single file like this.

Dinesh admin
Ganesh engineer
Anish ceo
Dev doctor
Jagan press
Gopi operation

can you please post your suggestions.

Thanks in advance,
Dinesh

szboardstretcher 03-15-2011 09:53 AM

Open up OpenOffice Calc, or Excel.

Open both files in notepad. Select all on first names, paste into one column. Select all on titles, paste into second column.

dinakumar12 03-15-2011 09:55 AM

Hi,

i am just want to achieve that through some command

szboardstretcher 03-15-2011 10:00 AM

What commands does it require? Awk? C++? Sed?

dinakumar12 03-15-2011 10:03 AM

awk.. would be fine.

grail 03-15-2011 10:09 AM

Code:

awk 'NR == FNR{_[FNR] = $0;next}{print _[FNR],$0}' file1 file2

dinakumar12 03-15-2011 10:15 AM

hi grail,

Thanks that works.


All times are GMT -5. The time now is 11:58 AM.