LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2013, 04:22 AM   #1
flacchy
LQ Newbie
 
Registered: May 2013
Posts: 17

Rep: Reputation: Disabled
remove multiple line with sed


hi,

I am trying to remove all the line containing this hit 'no hits found' from a big tabular file.

I have tried this command:

$ sed '/no\hits\found/d' filename

but is not waorking... can someone help me???

F.
 
Old 06-07-2013, 04:26 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,846

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
sed '/no hits found/d' filename
why did you replace spaces?
 
Old 06-07-2013, 04:34 AM   #3
flacchy
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
I have tried with no space, but is still not working

$sed '/no hits found/d' blastparse_protein.txt > blastparse_removed_no_hits
 
Old 06-07-2013, 04:40 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,846

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
for me that works perfectly, probably you mistyped or missed something. Can you please show us what was not working
 
Old 06-07-2013, 04:51 AM   #5
flacchy
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
those are some lines from my file :

NODE_26_length_67_cov_1.000000_2 17 No hits found
NODE_26_length_67_cov_1.000000_3 30 No hits found
NODE_26_length_67_cov_1.000000_4 11 No hits found
NODE_26_length_67_cov_1.000000_5 30 No hits found
NODE_26_length_67_cov_1.000000_6 32 YP_214377 346 recombin
ation endonuclease subunit [Prochlorococcus phage P-SSM2] 5e-13 60.5
0 1 32 6 37 87.5% 84.4%
YP_004322284 349 gp47 gene product [Synechococcus phage S-SM2] 2e-08 47.4 0 1 32 6 37 75.0% 65.6%
YP_004322556 348 gp47 gene product [Prochlorococcus phage P-HM1] 3e-08 47.0 0 1 32 6 37 75.0% 65.6%
NODE_46_length_1559_cov_67.561256_1 20 No hits found
NODE_46_length_1559_cov_67.561256_2 25 No hits found
NODE_46_length_1559_cov_67.561256_3 13 No hits found
NODE_46_length_1559_cov_67.561256_4 17 No hits found
NODE_46_length_1559_cov_67.561256_5 24 No hits found
NODE_46_length_1559_cov_67.561256_6 21 No hits found
NODE_46_length_1559_cov_67.561256_7 19 No hits found

---------- Post added 06-07-13 at 04:52 AM ----------

I need to remove all the lines with the No hits found argument
 
Old 06-07-2013, 04:53 AM   #6
flacchy
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
done sorry.. I was spelling no instead of No .. Thank you
 
Old 06-07-2013, 04:55 AM   #7
flacchy
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
Can I ask you.. how can I set the command in order to keep only the line with the NO hits found argument???
 
Old 06-07-2013, 05:25 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,846

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
if you want to say thanks just press YES.

I'm not really sure what do you need, try this:

sed '/no hits found/p;d' filename
or
grep 'no hits found' filename
 
Old 06-07-2013, 05:30 AM   #9
flacchy
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
Oh right ... grep should work ...

Thank you so much for the advice ^_^
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [bash] can't remove a line from a variable using sed Ari.G Programming 3 02-13-2012 10:01 AM
[SOLVED] using sed to remove all characters on a line except the first sorrymouse Programming 4 10-31-2011 10:33 AM
Using sed to remove all but the last 17 characters on a line simplified Programming 5 06-04-2010 03:33 AM
Trying to use sed to remove last line if it contains a certain string. slaxative Linux - Software 1 03-18-2008 02:13 AM
[SOLVED] sed: How to remove the end of a line? angel115 Programming 2 10-01-2007 10:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration