Sorting columns for specific values | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

Sorting columns for specific values

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-14-2013
AAWT AAWT is offline
Registered User
 
Join Date: Feb 2012
Last Activity: 6 June 2013, 5:38 AM EDT
Posts: 37
Thanks: 9
Thanked 0 Times in 0 Posts
Sorting columns for specific values

Dear All,
i have a column with values in excel table:

Code:
       
ATGC22327-p66       
ATGC15922-p239       
ATGC12710-p21743567     
ATGC08037-p186       
ATGC07969-p173       
ATGC07345-p48534    
ATGC02767-p254234  
 ATGC02124-p2177451
ATGC02124-p1459     
 ATGC01930-p3005

I need to have a new column with only value starting with p,
output should be

Code:
p66
p239
p21743567
p186

thanks for the help,
Best Regards
AAWT
Sponsored Links
    #2  
Old 03-14-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 31 October 2014, 9:36 PM EDT
Location: Saskatchewan
Posts: 19,745
Thanks: 832
Thanked 3,375 Times in 3,162 Posts
'in excel table'? Do you mean a CSV file, flat file, or actual xls file?
Sponsored Links
    #3  
Old 03-14-2013
AAWT AAWT is offline
Registered User
 
Join Date: Feb 2012
Last Activity: 6 June 2013, 5:38 AM EDT
Posts: 37
Thanks: 9
Thanked 0 Times in 0 Posts
Yes it is an excel file, I was trying to do in excel by opening text file,
this is actually a tab delimited text file
Best Regards
    #4  
Old 03-14-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 31 October 2014, 9:36 PM EDT
Location: Saskatchewan
Posts: 19,745
Thanks: 832
Thanked 3,375 Times in 3,162 Posts
Quote:
Originally Posted by AAWT View Post
Yes it is an excel file
Quote:
this is actually a tab delimited text file
These are not the same thing. Knowing it's tab-delimited text is good.

Knowing which column you wanted would also be nice... I'm assuming it's the first and only column, but 'tab separated' has little meaning when there's no columns!


Code:
awk -F"-" '{ print $2 }' inputfile

Sponsored Links
    #5  
Old 03-14-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 30 October 2014, 6:50 PM EDT
Location: Galactic Empire
Posts: 3,387
Thanks: 235
Thanked 1,209 Times in 1,135 Posts
Follow these steps:
  1. Make a copy of this column to another column
  2. Select all data in the new column
  3. Goto Data tab
  4. Select Text to Columns
  5. Specify hyphen - as delimiter
  6. Click Finish
Now you will have a new column with data starting with p
The Following User Says Thank You to Yoda For This Useful Post:
AAWT (03-14-2013)
Sponsored Links
    #6  
Old 03-14-2013
AAWT AAWT is offline
Registered User
 
Join Date: Feb 2012
Last Activity: 6 June 2013, 5:38 AM EDT
Posts: 37
Thanks: 9
Thanked 0 Times in 0 Posts
thanks, it works in excel,
but not in text file, it was second column,
Best Regards
Sponsored Links
    #7  
Old 03-14-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 31 October 2014, 5:47 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,480
Thanks: 8
Thanked 549 Times in 526 Posts
Import the text into excel, nsert a blank column to the right of the column with the -p's, select the text, and do data text to columns, spliting on '-', as mentioned above.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Adding columns with values dependent on existing columns plumb_r Shell Programming and Scripting 2 02-05-2013 01:51 AM
Print columns matching to specific values EAGL€ Shell Programming and Scripting 3 06-07-2012 08:50 AM
Removing columns from a text file that do not have any values in second and third columns evelibertine UNIX for Dummies Questions & Answers 3 11-22-2011 03:53 PM
Get values from different columns from file2 when match values of file1 cgkmal Shell Programming and Scripting 17 09-29-2011 05:03 AM
Sorting multi-column values from a specific file canimsin Shell Programming and Scripting 4 09-22-2010 08:13 AM



All times are GMT -4. The time now is 06:23 AM.