LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 05-21-2009, 04:27 PM   #1
tekmann33
Member
 
Registered: Nov 2006
Posts: 188

Rep: Reputation: 30
sed to remove specific lines in a file


I have a large file whose contents looks like this:

fkjdls;a
fdjksa;||
fdjksa;|fjkd;as|
fjdk;
fdjka;jfdsa||
fjkd;a|fjkd;saj|
fjkd;l

I want to only remove the lines that contain the double pipes that are together '||'.

Would I use 'sed' for this?

Any input would be appreciated.
 
Old 05-21-2009, 04:33 PM   #2
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 57
Grep should work: grep -v '||' largefilename >notsolargefilename


Dave
 
Old 05-21-2009, 04:35 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Yes you would =)

sed -i '/||/d' file


Cheers,
Tink
 
Old 05-21-2009, 04:41 PM   #4
cam34
Member
 
Registered: Aug 2003
Distribution: OpenSuse 11.1, SLES10, Fedora 11 & XP 4 Gaming *sniffs
Posts: 101

Rep: Reputation: 16
Or grep works too.....
grep -v \|\|
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
sed match last x lines of a file bradvan Programming 12 03-20-2009 12:18 AM
Substitute specific lines with lines from another file rahmathullakm Programming 4 01-10-2009 06:47 AM
Delete specific Range of lines Using sed , awk, grep etc. joyds219 Linux - Newbie 4 03-28-2008 09:59 AM
Replacing text on specific lines with sed or awk? Lantzvillian Linux - Newbie 5 10-17-2007 10:00 AM


All times are GMT -5. The time now is 02:08 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration