@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> hi, i'm trying to delete all paragraphs which first line matches my pattern. can someone help me? please.. :)
<1> Sure, but you have to define "paragraph" first.
<1> sed doesn't know what a paragraph is, but it is relatively easy to teach it.
<2> show sample input text, use rafb.net/paste
<0> after the paragraph there's an empty line



<0> uhm, one moment
<0> http://www.rafb.net/paste/results/8aZ8AN71.html
<0> thats an opera ini
<3> hi
<0> hi :)
<1> Erm, so you want to remove an INI file section, not delete a paragraph.
<0> uh, do i? where's the difference?
<3> how can i remove all lines containing a pattern from a file?
<1> airw: The difference is semantic.
<1> hawking: d
<1> airw: sed doesn't understand INI files nor prose.
<1> airw: /^[[]Filter Item Menu]/,/^$/d this may be close enough for your purposes.
<0> wow.. it works, many many thanks :)
<1> You can use \[ instead of [[] if you prefer. sed doesn't care though.
<0> why i dont have to quote the second ]?
<0> s/quote/escape
<1> Because ] is only special within a bracket expression.
<1> Most sed's will let you use \] if you like. All sed's will let you use []] if it makes you feel better.
<1> /[[]section[]]/ has a nice kind of symmetry to it.
<0> looks somehow nice, yes



<3> well I have lots of "localhost 2:0:0:0: rejecting I/O to dead device" messages in my /var/log/messages and when I do sed -e "/^.*rejecting.*$/d" it'll have lines like this :"localhost 2:0:0:0ice" "localhost ice" etc.
<0> and i've got another little question: how do match lines containing "foo" but not "bar"? it's somehow hard to google for "sed match but not"
<1> hawking: /rejecting/d is sufficient.
<1> hawking: Anchoring the match with ^ and $ and then unanchoring it with .* and .* is superfluous.
<1> airw: function makeMap
<1> airw: Oops.
<1> airw: http://wiki.hypexr.org/wikka.php?wakka=RegexFAQ
<0> thanks prec
<1> But basically: sed -ne '/foo/{/bar/!p;}'
<1> I'd write that: sed -e '/foo/!d;/bar/d' # print lines matching foo and not matching bar
<1> sed -ne '/foo/!d;/bar/!p'
<0> oh, i see, works great :)
<3> wow the file was 1Gb now it's 628K
<3> I love sed :-)
<0> i love prec ;-)
<3> hehe
<1> :P
<4> knock knock
<4> whats the deal with sed's regex support of non-greedy matches?
<4> trying to match a string with "everything upto" with .*?
<4> foo.*?bar
<5> dgtlhoon: you mean 'a[^a]*' - a followed by zero or more non-a chars?


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #sed
or
Go to some related logs:

ImportError: No module named threading
#linux
mac w32codec-all
kdrive segmentation fault
harassarah
changing ownership quakenet
mdadm: superblock on doesn't match others - assembly aborted
altboot.conf
#python
joomla readfile() has been disabled for security reasons



Home  |  disclaimer  |  contact  |  submit quotes