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 10-10-2010, 11:38 AM   #1
leonardo2887
LQ Newbie
 
Registered: Oct 2010
Location: Berlin
Posts: 5

Rep: Reputation: 0
merging columns from different files


Hello to everybody.

I have three files with the following structure:

file1
1 2 3 4
5 6 7 8

file2
9 10 11 12
13 14 15 16

file3
17 18 19 20
21 22 23 24

and I'd like to create a new file:

file4
1 2
5 6
9 10
13 14
17 18
21 22


I tried with awk, but I'm really new to this language... and I had no success...

It would be great if some of you could help me.

Thank you in advance,
Leonardo
 
Old 10-10-2010, 11:48 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Perhaps this will work (one of probably several methods):
Code:
awk '{printf $1" "$2"\n"}' file1 file2 file3 > file4
 
Old 10-10-2010, 11:54 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
awk '{print $1,$2}' file1  file2 file3
 
Old 10-10-2010, 12:45 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,167

Rep: Reputation: 890Reputation: 890Reputation: 890Reputation: 890Reputation: 890Reputation: 890Reputation: 890
man split cut paste

edit:
actually, the awks above are more appropriate.

Last edited by schneidz; 10-10-2010 at 12:47 PM.
 
Old 10-11-2010, 03:28 AM   #5
leonardo2887
LQ Newbie
 
Registered: Oct 2010
Location: Berlin
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by GrapefruiTgirl View Post
Perhaps this will work (one of probably several methods):
Code:
awk '{printf $1" "$2"\n"}' file1 file2 file3 > file4
Thank you very much. This one worked!
 
  


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
Splitting and Merging files using dd Disillusionist LinuxAnswers Discussion 2 03-07-2014 10:00 AM
Merging Data Files toshibalaptoplinux Linux - Newbie 6 12-15-2008 12:32 AM
Merging Two Files using C++ ckoniecny Programming 5 09-26-2006 10:00 AM
merging mpg files karhu Linux - Software 4 07-28-2005 06:25 AM
merging movie files ZaphyR Linux - Software 4 09-05-2004 09:26 AM

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

All times are GMT -5. The time now is 12:26 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