Deleting unwanted text from a table


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Deleting unwanted text from a table
# 1  
Old 09-03-2014
Deleting unwanted text from a table

Hi everyone,

I have a microbial diversity table in the format ;k__kingdom; p__phylum, etc, somer rows have descriptions before the :k__ (like the af028349.1 below) is there a way I can get rid of this text (which is different every time) and keep all the other columns?

Thanks a bunch!
Code:
; k__bacteria; p__firmicutes; c__clostridia; o__clostridiales; f__lachnospiraceae; g__roseburia; s__roseburia spp.	171	78	11	117	99	43	98	79	119	48	254	6	15	10	60	10	16	81	31	58
af028349.1 clostridium fusiformis cm973 ; k__bacteria; p__firmicutes; c__clostridia; o__clostridiales; f__lachnospiraceae; g__clostridium;s__clostridium fusiformis cm973	82	67	8	30	143	23	99	29	43	186	186	36	87	21	32	20	5	18	21	305
; k__bacteria; p__firmicutes; c__clostridia; o__clostridiales; f__lachnospiraceae; g__coprococcus; s__coprococcus spp.	46	132	4	75	103	7	87	0	2	159	43	4	7	4	17	135	11	120	122	51
; k__bacteria; p__actinobacteria; c__coriobacteria; o__coriobacteriales; f__coriobacteriaceae; g__enterorhabdus; s__enterorhabdus spp.	73	25	151	39	20	23	55	17	75	57	25	110	12	151	132	56	73	66	37	47
; k__bacteria; p__proteobacteria; c__betaproteobacteria; o__burkholderiales; f__alcaligenaceae; g__parasutterella; s__parasutterella spp.	180	164	257	136	52	112	81	170	73	61	99	294	37	111	222	282	233	367	287	176


Last edited by vbe; 09-03-2014 at 05:22 PM.. Reason: code tags please
# 2  
Old 09-03-2014
Assuming the line you wanted was
Code:
; k__bacteria; p__firmicutes; c__clostridia; o__clostridiales; f__lachnospiraceae; g__clostridium;s__clostridium fusiformis cm973	82	67	8	30	143	23	99	29	43	186	186	36	87	21	32	20	5	18	21	305

...this will delete all text before the first ;
Code:
sed 's/^.*;/;/' inputfile > outputfile

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to change name of the file with first line of the file which has some unwanted text in it?

I have a log file, which i have divided into 14 files using csplit, the file looks like below test-000000 test-000001 #and so on until 14 now I want all the 14 files generated to be renamed as the some part of test in first line of the file how can i eliminate the unwanted text? sample... (5 Replies)
Discussion started by: Sekhar419
5 Replies

2. UNIX for Dummies Questions & Answers

Deleting the unwanted data based on condition

hi i have my input data like this aaa bbb ccc asa dff nmj mnj saa dff oik aax cdx saa oik asq sdf dssi want my output file to be like this mnj saa dff oik aax cdx saa oiki want to retain only those lines which will have oik just below them and i want oik to be as next column to those... (1 Reply)
Discussion started by: anurupa777
1 Replies

3. Solaris

deleting unwanted files solaris

Hi All, I want to clean my Solaris Server ( Removing Unwanted files and folders in Server ) .Kindly any one tell me the steps in doing this activity, regards Rj (1 Reply)
Discussion started by: jegaraman
1 Replies

4. Shell Programming and Scripting

remove unwanted text using perl

Hello..I have a text file that need to remove unwanted text. This is the original file. No. Time Source Destination Protocol Info 16 0.649949 10.1.1.101 209.225.11.237 HTTP POST /scripts/cms/xcms.asp HTTP/1.1 ... (9 Replies)
Discussion started by: taxi
9 Replies

5. Shell Programming and Scripting

rm -i and deleting files from an index table

Hi, I am trying to make a command to delete my files out the trash can, but one at a time. I am currently using rm - i to do this, but the original file locations for restoring my files are heard on a .txt file which I am using as an index table. How would I manage to make it so that if I... (21 Replies)
Discussion started by: E-WAN
21 Replies

6. Shell Programming and Scripting

PHP header text/csv unwanted line feed character

We have successfully created a comma delimited file, the results are correct from an sql database query. When using the following headers to print the file using print $data, an extra line feed is added and a blank row appears on the top of the data in Excel: header("Expires: 0"); ... (0 Replies)
Discussion started by: ifimbres
0 Replies

7. Shell Programming and Scripting

how can I bcp out a table into a text file including the header row in the text file

Hi All, I need to BCP out a table into a text file along with the table headers. Normal BCP out command only bulk copies the data, and not the headers. I am using the following command: bcp database1..table1 out file1.dat -c -t\| -b1000 -A8192 -Uuser -Ppassword -efile.dat.err Regards,... (0 Replies)
Discussion started by: shilpa_acc
0 Replies

8. OS X (Apple)

OS/X 10.4 Deleting unwanted applications

What is the correct way to delete unwanted applications from a MACbook running OS/X 10.4.1.1. It is sufficient to drag and drop from Applications folder to Trash, then clear Trash? (2 Replies)
Discussion started by: methyl
2 Replies

9. Shell Programming and Scripting

Deleting table cells in a script

I'd like to use sed or awk to do this but I'm weak on both along with RE. Looking for a way with sed or awk to count for the 7th table data within a table row and if the condition is met to delete "<td>and everything in between </td>". Since the table header start on a specific line each time, that... (15 Replies)
Discussion started by: phpfreak
15 Replies

10. Shell Programming and Scripting

cutting unwanted text

Hello, I have a log file which looks like this : I want to cut out some text and get printed only : "HTTP GET" and "Time duration: 1013 mls. (1 sec.)" I tried searching the forum for such solution, but I was unable to find it. I also tried awk '/duration/ { print $0 }' mylogfile.log,... (2 Replies)
Discussion started by: sysgate
2 Replies
Login or Register to Ask a Question