Sorting columns for specific values


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sorting columns for specific values
# 1  
Old 03-14-2013
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
# 2  
Old 03-14-2013
'in excel table'? Do you mean a CSV file, flat file, or actual xls file?
# 3  
Old 03-14-2013
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
Quote:
Originally Posted by AAWT
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

# 5  
Old 03-14-2013
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
This User Gave Thanks to Yoda For This Post:
# 6  
Old 03-14-2013
thanks, it works in excel,
but not in text file, it was second column,
Best Regards
# 7  
Old 03-14-2013
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting by columns

Hi, I have a tab delimited columnar file where I want to remove lines wherever two particular columns match. so for this file, I want to toss the lines where columns 1 and 2 match: a a 1 3 a b 2 4 b b 3 5 because there are matches column 1 and 2 in lines 1 and 3, I would like a script to... (2 Replies)
Discussion started by: mikey11415
2 Replies

2. UNIX for Dummies Questions & Answers

Printing lines with specific strings at specific columns

Hi I have a file which is tab-delimited. Now, I'd like to print the lines which have "chr6" string in both first and second columns. Could anybody help? (3 Replies)
Discussion started by: a_bahreini
3 Replies

3. Shell Programming and Scripting

Adding columns with values dependent on existing columns

Hello I have a file as below chr1 start ref alt code1 code2 chr1 18884 C CAAAA 2 0 chr1 135419 TATACA T 2 0 chr1 332045 T TTG 0 2 chr1 453838 T TAC 2 0 chr1 567652 T TG 1 0 chr1 602541 ... (2 Replies)
Discussion started by: plumb_r
2 Replies

4. Shell Programming and Scripting

Can't figure out how to find specific characters in specific columns

I am trying to find a specific set of characters in a long file. I only want to find the characters in column 265 for 4 bytes. Is there a search for that? I tried cut but couldn't get it to work. Ex. I want to find '9999' in column 265 for 4 bytes. If it is in there, I want it to print... (12 Replies)
Discussion started by: Drenhead
12 Replies

5. Shell Programming and Scripting

Help in sorting multiple columns

Hello all, I am using printf to print the sorted o/p in my script.I am trying to sort in following way but doesn't work. printf "%13s %2s UDP %15s:%s Program %4s HD: %23s HD: %23s %10s %s %s %3s days %3s hours\n" $encoder $i "${ipaddr}" ${portno} ${progno} ${inres} ${outres} ${inrate}... (4 Replies)
Discussion started by: ramman
4 Replies

6. Shell Programming and Scripting

Print columns matching to specific values

Hello Friends, I have a CDR file and i need to print out 2 columns with their field position which matches to some constant values, a part of input file CZ=1|CZA=1|DIAL=415483420001|EE=13|ESF=1|ET=|FF=0|9|MNC=99|MNP=9041|MTC=0|NID=2|NOA=international|ON=1| OutPut ... (3 Replies)
Discussion started by: EAGL€
3 Replies

7. Shell Programming and Scripting

sorting and adding columns

i have a file with two columns, and i want to uniquely sort the values in fist column and add the corresponding values in the second columns eg file a contents tom 200 john 300 sow 500 tom 800 james 50 sow 300 output shpould be in file b as tom 1000 john 300 sow 800 james 50 (0 Replies)
Discussion started by: dealerso
0 Replies

8. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

9. Shell Programming and Scripting

Get values from different columns from file2 when match values of file1

Hi everyone, I have file1 and file2 comma separated both. file1 is: Header1,Header2,Header3,Header4,Header5,Header6,Header7,Header8,Header9,Header10 Code7,,,,,,,,, Code5,,,,,,,,, Code3,,,,,,,,, Code9,,,,,,,,, Code2,,,,,,,,,file2... (17 Replies)
Discussion started by: cgkmal
17 Replies

10. Shell Programming and Scripting

Sorting multi-column values from a specific file

Hi, all. I need a shell script which gathers data from a remote XML file and then displays it according to my needs.. I need this for my job due to the fact that I need to keep track price changes of euro, usd, gold, etc. The XML file I am talking about is located at this page: cnnturk dot... (4 Replies)
Discussion started by: canimsin
4 Replies
Login or Register to Ask a Question