@# Quotes DB     useful, funny, interesting





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


Comments:

<0> i want to write a quick script that fixes c++ source code based on a compiler error
<0> i am deleting an implicit conscructor for a popular cl*** in KDE
<0> which could take days by hand
<1> ehmm.
<0> basically i will get FILE:LINE: error: no matching function for call to FUNCTIONAME (...,..., QString,...)
<0> canditaes are: FUNCTIONSNAME (...,..., KGuiItem, ...)
<1> My C++ is poor.
<0> and I need sed to just edit the function that ends on that line
<1> Step 1: parse the error log, finding the file:line pairs.
<0> and s/param/KGuiItem(param)/;



<1> Step 2: generate a script from the file:line pairs to edit each one
<1> step 3: run the script.
<0> ok
<0> for example
<1> I'd probably use ed for this.
<0> I have to change the 4th parameter of the functions ending on FILE:line 10
<1> Of course, you can use GNU sed's -i option, or the standard sed method: sed -e script <file >file.new && mv file.new file
<0> the file could be like:
<0> 8: function ( param1,
<1> You'll still have to look out for weird cases.
<0> 9: param2,
<0> 10: param3, param4 );
<1> Yes, cases which span multiple lines.
<0> or i could get:
<1> Those will be a problem.
<0> line 9: function ( (1+2),
<0> line 10: (1+2), (1+2), param4);
<0> with nested parens
<1> Even more problems, as sed can't count those.
<0> maybe this is a job for perl
<1> Well, sed _could_ count parentheses, but you have to teach it how.
<1> perl can't count parentheses either, you have to teach it too.
<1> You could cheat and look for ); instead.
<1> That's easier.
<1> In fact, I did this the other day ...
<1> too bad I lost it.
<0> lol
<2> how do i make sed to replaces ALL newlines with \\n's , except those lines which end with "
<2> the goal is to convert text having embedded newlines with quotes into \n's
<2> basically tell sed , \"\n = do nothing , \n = \\n
<1> Pkunk: FAQ
<2> man .. thats gonna take me a month to master
<1> fulld: sed -e '42{ :1' -e '/);/!{N;b1' -e '}; s/[^,]*);/XXX/;}'
<1> Pkunk: heh.
<1> Pkunk: I'm not sure what you mean by embedded newlines ...
<2> its a database dump in csv format
<2> some fields have non \quote newlines
<0> prec: wow dude
<1> Pkunk: sed -e :1 -e '/"$/!{N;s/\n/\\\\n/;b1' -e '}'



<1> fulld: Where '42' is the line number in question.
<2> within " " quotes
<2> that doesn't work right , prec .. it doesn't even delete the newlines
<1> Pkunk: You really need a csv parser instead.
<2> postgresql can't handle the embedded newlines
<1> Pkunk: Care to paste a few sample input lines? http://www.rafb.net/paste/
<2> for example , 1,2,3,4,"Line 1
<2> Line 2
<2> Line3",nextfield
<2> everything needs to come within one line
<1> OK, well, the third line there does not end in ". Should sed join it with the next line? :/
<2> basically convert to "line 1\nline 2\nline 3",nextfield
<1> Pkunk: Right, but then sed needs to track when it is in a quote and when it isn't ...
<2> not necessiry
<1> Most definitely...
<2> all "proper" lines end with "
<2> nextfield is quoted
<1> You just pasted a line which doesn't end in "
<1> OK, I see.
<1> What about another edge case? A field whose contents are >>"foo"NEWLINEbar<< is encoded as: """foo""
<1> bar"
<1> ;)
<2> its all simple data . no quote-hell here
<1> It's not simple, it has embedded newlines!
<1> The point I'm failing to make is that a simple solution will fail miserable in the future and break stuff.
<2> there is no future
<2> its a one time db conversion
<1> Ah, OK.
<1> Well, then whatever converts it will work.
<2> your line doesn't work
<1> http://www.rafb.net./paste/results/tHt6GJ71.html
<1> That one works for me. It only differs from my previous solution be writing \n instead of \\n
<1> s/be writing/by writing/
<1> printf '#!/bin/sed -f\n\n:1\n/"$/!{\n\tN\n\ts/\\n/\\\\n/\n\tb1\n}\n' >Pkunk.sed
<1> printf '"field1","field\ntwo","field3"\n' >Pkunk.in
<1> sed -f Pkunk.sed Pkunk.in
<1> "field1","field\ntwo","field3"
<1> Pkunk: Does that work?
<2> sec , i was trying my own cmd so i din't notice
<2> kewl , works great
<2> the problem was the .csv was msdos format
<2> converted it to unix
<2> thanks a lot
<1> np.
<3> hello folks, i have file1 in which there are 4000 words and there is another file file2 which has 1000 words which i need to delete from the contents in file1, how should i go about it using sed ? any recommendations ?
<1> smagy2: grep -v -f file2 file1


Name:

Comments:

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






Return to #sed
or
Go to some related logs:

powerofsatan
#python
atal error: Maximum execution time php
static function unexpected T_STATIC
play encrypted real audio linux
ubuntu xgl ati radeon igp 320
nvidia alc880 ubuntu install
#math
webfoundation.net
audacious double-size



Home  |  disclaimer  |  contact  |  submit quotes