LinuxQuestions.org
Review your favorite Linux distribution.
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, 10: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, 10:53 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,094

Rep: Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515
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, 10:55 AM   #3
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
Hi,

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

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

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

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

Original Poster
Rep: Reputation: 18
hi grail,

Thanks that works.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:44 AM
how to paste the content of 2 files onto 1 line (in a file)? PatrickBecks Programming 2 02-14-2008 07:41 AM
Writing /etc files to a new file strello Linux - Newbie 4 11-19-2006 07:47 PM
Writing Single files to a CD jimmmac Linux - Software 11 04-27-2003 05:20 PM


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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration