| |
| |
| |
|
Comments:
<0> pkrumins: // means "use the last used pattern" <0> Hence: sed '/foo/!d;s//bar/g' shows only lines matching /foo/ while replacing all occurences of foo with bar. <1> how would i do a non greedy grab of everything between xyz and the very next semicolon? <1> i'm looking for something like sed -e 's/xyz.*;/FOOBAR/', but the asterisk is taking everything up to the last ';' in the line <2> hi all, I want to run a script with switches (like sh script param1 param2), within the script I need to use sed to replace some strings by 2nd switch, I've tryed sed -e 's/.*/&'$2'/', but don't woks, how can I do that? <3> anything inside '' is taken literally. <3> "s/.*/&$2/" , or 's/.*/&'"$2"'/' should work. <3> although i read somewhere using "s///" is bad. dunno why <2> goldfish: thanks <2> Rado: thanks <4> hi. I see this in a script sed -n -e "s#^$RPM_BUILD_ROOT##p"
<4> what does the '#' symbol do? <4> shouldn't it be '/'? <5> it is instead of / <5> you can use "whatever" character instead of / <4> so does the following cmd remove every line that has $RPM_BUILD_ROOT <3> nope <5> it is used when you want to use / in substitution, and you don't want to make it clumsy with all those <5> \/ <3> well <3> use "d" if you want to actually DELETE <3> sed "/^$RPM_BUILD_ROOT/d" <4> so why two '##'? doesn't that mean to replace refernces of $RPM_BUILD_ROOT with nothing <5> it doesn't matter whether there is / or # <3> adp: it does. but it wont delete the whole line <4> goldfish: ok. got it. <2> please give a rope, I need to p*** the 2nd parameter of a script ( $2 ) to sed to it replace a string by the value of the parameter, I can not find how to do that... <6> Dantix: what do you have as the command right now? <2> rawtaz_: sh script param1 param2 <6> inside the script then? the sed line <2> rawtaz_: s/.*/&{$1}/ <2> rawtaz_: sorry, that is wht my sed command file contains <3> hmmmmm. <2> rawtaz_: I'm calling sed this way: sed -f sed.cmd <3> (***ume bash) #!/bin/bash sed "s/string/$2/" file <2> goldfish: that replaces string by $2 not by the value of the shell variable, I've just tested that <3> it does not. <3> you probably have it inside single quotes. <3> not double quotes. <3> In which case it would replace it with a literal $2, as anything inside '' is taken literally. <2> goldfish: let me test it <2> goldfish: this is my script: cat $2|cut -f1|sed 's/.*/&$1/' and I'm running: sh script @foo.com test.txt and it replaces the string matched by "cut" by $1 not by @foo.com <3> yes. <3> You just ignored what I said. <3> It's inside single quotes, anything inside single quotes is taken literally, use double quotes. <6> indeed <3> also, no need for cat, sed can work on files, and you can most likely get rid of the cut. and just use sed. <2> goldfish: mmm, sorry, perhaps my bad english...I'll try again <3> sed "s/.*/&$1" <2> goldfish: works!, thanks you very much by your help and patience :) <3> No problem. <3> cat $2| cut -f1| sed .... can be replaced with "cut -f1 $2| sed ...." <3> Although, as I said, you can do it all in sed, but i think we'll leave that for another day's learning. <2> goldfish: thanks again <3> np. <7> Hmm, what does this regex match? /^\([ -~]*\n\).*\n\1/ <7> Particularly [ -~]* is not clear to me <3> a space, a -, or a ~, zero or more times. <7> nope <3> nope?
<7> i exchange [ ~-]* <7> and it no longer produces the same resut as [ -~]* <7> any ideas? <7> goldfish, btw, talking about the yesterday's sed expression here is the answer: http://groups.google.com/group/comp.unix.shell/browse_frm/thread/b3885f5692585f64/1b43f015da0dfec3#1b43f015da0dfec3 <7> I am now deciphering this sed expression: sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' <7> which does eliminate nonconsecutive duplicate lines <3> jesus. <3> Some complicated stuff right there :) <7> not too complicated <7> just the [ -~]* <3> well, i meant the explanation of yesterday's stuff. <7> yes, that was pretty tricky <3> well, i'm an idiot. <3> heh <7> takes time to become sed master <3> [a-z] matches a to z <7> sure <3> so [ -~] matches space to ~ <7> but [-az] matches -, a or z <3> indeed. <7> you think it matches space to ~? <3> yes <3> although i'm not sure what way that works. <7> where is my ascii chart table <3> ascii values maybe? <3> man ascii <3> has it :) <7> wow :) <7> didnt know <7> ha <7> pretty cool <7> it matches all printable chars <3> handy alright. <7> then <3> Oh rigt. <7> space is 0x20 <7> and ~ is 0x7E (176 dec) <7> pretty cool <7> wow nice trick <7> match all printables [ -~] <7> and 177 dec is DEL which is no longer printable just after ~ <3> i see <7> makes sense and i fully understand this expression now. <7> thanks goldfish <7> :) <3> np. <3> man 7 regex <3> is a decent resource, also. <7> wow pretty good <7> you know some more valuable man pages? <3> well. it depends on what you value. <3> man man , is valuable :) <3> the -k option of man, searches.... <3> That's helpful at times. <7> great <7> man woman :) <7> unfortunately does not exist
Return to
#sed or Go to some related
logs:
mozilla sirefox inetd xwin fedora mounting /dev/root failed, dapper suse_register fails supremedestiny boot what do the dell 600m keyboard lights mean php6+$_get gentoo warning unable to open an initial console #egghelp gettext not translating
|
|