LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-03-2010, 09:16 PM   #1
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 168

Rep: Reputation: 15
Remove all lines containing 'A,,,,,,'


How can I remove all lines which contain A,,,,,,

I tried the following sed statements but no luck.

Code:
sed "/A,,,,,,/d file"
sed "/A\,\,\,\,\,\,/d file"
Thanks & Regards
 
Old 11-03-2010, 09:59 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
Quote:
Originally Posted by hattori.hanzo View Post
Code:
sed "/A,,,,,,/d file"
sed "/A\,\,\,\,\,\,/d file"
You just have a misplaced quote, you only need to quote the sed command, not the filename, ie:
Code:
sed '/A,,,,,,/d' file
 
1 members found this post helpful.
Old 11-03-2010, 10:06 PM   #3
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 168

Original Poster
Rep: Reputation: 15
Apologies, typo on my part.

Still doesnt appear to work tho.

Code:
sed '/A,,,,,,/d' file
 
Old 11-03-2010, 10:25 PM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by hattori.hanzo View Post
Apologies, typo on my part.

Still doesnt appear to work tho.

Code:
sed '/A,,,,,,/d' file
Well, since the sed is correct you will have to provide some sample data. Miscounted the number of ','? Any whitespaces in between ...?
 
Old 11-03-2010, 10:29 PM   #5
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 168

Original Poster
Rep: Reputation: 15
OK. Here is a sample. I need to remove the middle line.

Code:
2010-10-04 00:07:33,9780009689,57641534,A,com,d,c,b,,
2010-10-04 00:07:35,3867802220,179041534,A,,,,,,
2010-10-04 00:07:36,7860502220,988941534,A,com,d,c,b,a,
Thanks & regards
 
Old 11-03-2010, 10:37 PM   #6
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Just copy+pasted your sample data, then copy+pasted the sed command and it works perfectly.
Maybe you want the -i option to modify the file permanently?
sed -i '/A,,,,,,/d' file
 
1 members found this post helpful.
Old 11-03-2010, 11:09 PM   #7
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 168

Original Poster
Rep: Reputation: 15
Its resolved thanks.

I had this statement in the middle of a script which didnt work so I changed it. But it definitely works works as expected at the command line. Thanks.
 
  


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] how to remove X lines from output hurryi Linux - Newbie 5 10-11-2010 05:40 AM
How to remove lines and parts of lines from python strings? golmschenk Programming 3 11-26-2009 11:29 PM
How do I remove lines that have more than one of a certain character in them? SentralOrigin Linux - General 2 01-14-2009 01:40 PM
How to remove the first part of lines? daYz Linux - Software 3 11-26-2005 06:09 PM
How to remove lines from a file doza Linux - General 2 04-27-2005 11:59 AM

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

All times are GMT -5. The time now is 10:17 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