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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove lines, Sorted with Time based columns using AWK & SORT karthikn7974 Shell Programming and Scripting 1 05-09-2008 11:04 PM
sort columns by field kamel.seg Shell Programming and Scripting 4 02-20-2008 06:50 AM
Help needed to sort multiple columns in one file ahjiefreak UNIX for Dummies Questions & Answers 1 12-07-2007 05:50 AM
have a file with 300 columns dummy_needhelp Shell Programming and Scripting 4 11-05-2007 01:08 AM
Sort by Columns murbina UNIX for Dummies Questions & Answers 1 05-10-2004 02:21 PM

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 12-11-2007
kamel.seg kamel.seg is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 57
add columns from file to another and sort

hi,

i have probleme to extract the columns info from file to another one;
FILE A look like :


x,inof1
y,inof1
z,info2
t,inof3


and FILE B like
x
t
w
d
z

i want to add correpondant columns (info) to each line of FILE B and sort this file by this columns.

lines in FILEA and B are not sorted .
thanks
  #2 (permalink)  
Old 12-11-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
what is the final result based on the sample files given above?
  #3 (permalink)  
Old 12-11-2007
kamel.seg kamel.seg is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 57
the final result is FILE B:

x,info1
t,info3
w infox
d infoxx
z info2

and after sort:

FILE B

x,info1
z info2
t,info3
w infox
d infoxx

that depends of infox and infoxx cause i have many lines in this file

thanks
  #4 (permalink)  
Old 12-11-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by kamel.seg View Post
the final result is FILE B:

x,info1
t,info3
w infox
d infoxx
z info2

and after sort:

FILE B

x,info1
z info2
t,info3
w infox
d infoxx

that depends of infox and infoxx cause i have many lines in this file

thanks
  1. where does the 'infox' comes for 'w' in fileB? There's no corresponding entry in FILEA
  2. how come there's no ',' field separators for the z,w and d records in FILEB?
  3. What are the actual values for 'info1', info2 .... infox? Are they numeric, alphanumeric?
  4. How to determine 'info1 < infoN'?
  #5 (permalink)  
Old 12-11-2007
bobbygsk bobbygsk is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 90
Use "paste" and "sort -u" command
  #6 (permalink)  
Old 12-12-2007
kamel.seg kamel.seg is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 57
infox or info1 are alphanumeric also x,y,z ...
i use abreviation for line cause i want to print the the line "line" in the correspondant line .

the line x y z are the same in two files there is no comma in the two file only space betwen linex , y or z and line info.

i can't use paste cause the FILEB and FILEA are not sorted.

thankx
  #7 (permalink)  
Old 12-12-2007
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Quote:
Originally Posted by kamel.seg View Post
infox or info1 are alphanumeric also x,y,z ...
i use abreviation for line cause i want to print the the line "line" in the correspondant line .

the line x y z are the same in two files there is no comma in the two file only space betwen linex , y or z and line info.

i can't use paste cause the FILEB and FILEA are not sorted.

thankx
What about sorting those files and then merging them on the similar column(s) using the paste command? Is there a reason why you choose not to use sort?
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 05:35 PM.


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