LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-15-2011, 09:49 AM   #1
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Rep: Reputation: 18
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
 
Old 03-15-2011, 09:53 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
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.
 
Old 03-15-2011, 09:55 AM   #3
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271

Original Poster
Blog Entries: 7

Rep: Reputation: 18
Hi,

i am just want to achieve that through some command
 
Old 03-15-2011, 10:00 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
What commands does it require? Awk? C++? Sed?
 
Old 03-15-2011, 10:03 AM   #5
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271

Original Poster
Blog Entries: 7

Rep: Reputation: 18
awk.. would be fine.
 
Old 03-15-2011, 10:09 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Code:
awk 'NR == FNR{_[FNR] = $0;next}{print _[FNR],$0}' file1 file2
 
1 members found this post helpful.
Old 03-15-2011, 10:15 AM   #7
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271

Original Poster
Blog Entries: 7

Rep: Reputation: 18
hi grail,

Thanks that works.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get input from log file horizontally tux.amit Programming 1 12-22-2009 12:44 AM
how to paste the content of 2 files onto 1 line (in a file)? PatrickBecks Programming 2 02-14-2008 06:41 AM
Writing /etc files to a new file strello Linux - Newbie 4 11-19-2006 06:47 PM
Writing Single files to a CD jimmmac Linux - Software 11 04-27-2003 04:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration