The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
merging two files rameshonline Shell Programming and Scripting 14 04-06-2009 01:20 AM
Need help in extracting columns praveenbvarrier Shell Programming and Scripting 6 04-03-2008 02:06 AM
Merging two files venommaker UNIX for Dummies Questions & Answers 4 01-10-2008 08:15 AM
merging two files based on some key Vandana Yadav Shell Programming and Scripting 1 02-03-2006 09:45 AM
merging few columns of two text files to a new file kolvi Shell Programming and Scripting 4 09-15-2005 04:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-22-2005
kingkong kingkong is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 18
Extracting columns from different files for later merging

Hello!

I wan't to extract columns from two files and later combine them for plotting with gnuplot. If the files file1 and file2 look like:

fiile1:
a, 0.62,x
b, 0.61,x

file2:
a, 0.43,x
b, 0,49,x
The desired output is

a 0.62 0.62
b 0.61 0.49

Thank you in advance!
  #2 (permalink)  
Old 11-22-2005
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,723
I'm guessing you mistyped your expected results:

using file1:
Code:
a, 0.62,x
b, 0.61,x
file2:
Code:
a, 0.43,x
b, 0.49,x
output:
Code:
a 0.62 0.43
b 0.61 0.49
code:
Code:
tr -s ',' ' ' < file1 > newfile1
tr -s ',' ' ' < file2 > newfile2
join newfile1 newfile2 | awk '{print $1,$2,$4}'
  #3 (permalink)  
Old 11-23-2005
kingkong kingkong is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 18
Thank you very much! The code works excelent!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0