| |
| |
| |
|
Page: 1 2
Comments:
<0> how can I replace a bunch of spaces with a single comma? <1> s/ */,/ <0> prec: thank ya :) <1> Sure. <2> hi. anybody know how to reference a substring that's matched by a regexp ? <2> like perl's $1 $2 stuff <1> s/\(foo\)\(bar\)/\2\1/ <2> should i be using grep if i'm not doing a substition at all? <2> i just want to extract a portion of text from a line <2> but then grep prints lines... <1> GNU grep has -o <2> sounds like that would do. <2> so it's not a job for 'sed' though? <1> one sec. <2> actually. what i need to do is. like perl's =~ /VERSION=(.*)/ <1> http://www.rafb.net./paste/results/aFx9Yg76.html
<2> so i get what's after VERSION= as $1 <1> Everything is after VERSION= <1> sed -e '/VERSION=/!d;s///' <2> ok. i wasn't being fair. <2> hold on <2> export LTSP_KERNEL_VERSION="2.6.16.17-ltsp01" <2> this is my string <2> i need the 2.6.16.17-ltsp01 part <1> sed -e '/^LTSP_KERNEL_VERSION=/!d;s///;s/"//g' <2> returns nothing <1> sed -e '/^export LTSP_KERNEL_VERSION=/!d;s///;s/"//g' <1> oops. <2> so. it looks like sed uses \(.*\) to match regions. then refers to them as \1 ? <2> so i would match and replace the whole line with the match only ? <2> i.e do a substition although i don't need to <1> Hmm? <1> sed -ne 's/^export LTSP_KERNEL_VERSION="\([^"]*\)"$/\1/p' <1> That will work too. <2> sed -e 's/export LTSP_KERNEL_VERSION=\(.*\)/\1/' <2> this works. though i don't know why it handles the double quotes <1> Handles? <2> first things first <1> sed doesn't care about double quote characters -- they are just ordinary characters to sed. <2> sed -ne 's/^export LTSP_KERNEL_VERSION="\([^"]*\)"$/\1/p' didn't work <2> second. <2> sed -e 's/export LTSP_KERNEL_VERSION=\(.*\)/\1/' <2> works. but i was expecting it to return "2.6.16.17-ltsp01" <2> but it returned 2.6.16.17-ltsp01 <2> which is what i want. but. how does it know that. i don't get. <1> It doesn't. <2> oh <2> it must be a shell substition thing <1> That'd be my guess. <2> right <2> so i'll try your version again without involving the shell <2> works <2> this is actually the output of a command but i was just echo'ing a constant string for testing <2> mine works too when i add the double quotes <2> can you explain the difference ? <2> [^"] what does that mean? <2> at the beginning ? <2> or negation? <1> Without invoking the shell? Hmm. <2> nah. <1> [^"] matches a single non-quote character. <2> oh and * matches all single non-quote characters <2> until the double quotes at the end <2> ? <1> No, * does not match. <2> quantifier no? <2> 0 or more <1> Yes. * is the same as \{0,\} <2> awesome. <1> Which means "match zero or more of the preceding item" <2> ok. just like perl. great. <2> thanks very much. i think i've got enough to work with. <1> OK. :) <2> later <3> Evening. <3> What I need is a math for a string which is a max of 4 chars long and starts at the line. <3> Further more it only the number in one line.
<3> I have gotten this. <3> s/^[0-9]\{1,4\}//p <3> I just want to print the match <3> Nothing else. <4> WoodyWoodpecker: sed -n '/^[0-9]\{1,3\}/p' filename <3> gnubien: But 1,3 isn't that a maximum of 3 chars? <4> WoodyWoodpecker: ok, try 1,4 <3> I didn't try, I just wondered. <3> It it not mine anyway. <3> But thank you anyway. <4> have fun ;) <3> lol, sure I will ^^ <5> HI all.can sed use with environment variables? <5> for example,sed -e 's/$USER/fog/' ... <6> yes, you can <6> by using the right quotes to allow your shell to substitute the variable <6> echo $USER; echo "$USER"; echo '$USER' - not sed's fault <7> hum....how can i delete the first line in patten space which have mutil lines content,and don't use "D" ? <7> thx <4> giant: post an example line you want to delete <7> gnubien:i ***ume there are 3 lines in my partten space now <7> first line:1 <7> second line:2 <7> third line:3 <7> and i wanna del the first line <7> how to do it ?thx! <4> giant: line 1,2,3 are all one long line? <4> giant: line 1,2,3 each ended with a newline char? <7> each number occupys one line in mpatten space. <7> yep <7> how to express the "newline char" if i use s(earch) command to patten space ? <4> newline == \n like echo -e "1\n2\n3\n" <8> regex q: how to replace string part after last 'x' occurance wih 'y'? i.e. asxfooxbar -> asxfooxy <9> s/^\(.*x\)[^x]*$/\1y/ <4> MZM: echo "asxfooxbar" |sed 's/^\(.*x\)[^x]*$/\1y/' #asxfooxy <9> giant: if you have all three lines in pattern space (N;N) then you delete first like this: s/^[^\n]*\n// <8> tnx <9> echo -e "1\n2\n3" |sed 'N;N;s/^[^\n]*\n//' <9> echo -e "1\n2\n3\n" <7> helloman:hum... <9> clear? <7> yep,but...not work. <9> what doesn't work? <7> wait for a moment . <7> helloman:your script seems delete all lines except the last line. <7> it will find the first "\n" and delete the line,the continue to find the second "\n" and delete the line also...... <9> what exactly do you want to do with those three lines? <7> just delete the first line! <7> delete "1\n" <9> well, sed '1d' <7> ... <9> it is in pattern space, well? <7> yep,these 3 lines are in the pattern space <9> then s/^[^\n]*\n// must work <7> hum...do you konw which site provides the similar service likes pastebin.com? <9> every free webhosting :) <4> giant: pastebin.ca <7> get it <7> http://cpp.enisoc.com/pastebin/7393 <9> wau <9> what do you want the result to be? <7> i paste it just wanna explain that your script search "\n" in lines one by one,instead of delete all lines between "^" and the last "\n" once . <7> i paste it just wanna explain that your script search "\n" in lines and delete the line one by one,instead of delete all lines between "^" and the last "\n" once . <9> but if you delete all lines between ^ and last \n you do not delete first line as you wanted, but everything but the last one <9> if you have "1\n2\n3" in pattern space s/^[^\n]*\n// results in "2\n3" <7> ok,i didn't discribe it clearly.sorry for my lame english. <9> mine is alse lame <7> e,but seems not get the result in "2\n3" <9> also <7> the result is "3" <7> PATT:2 <7> HOLD: <7> 1
Return to
#sed or Go to some related
logs:
totem-exine
#centos perl use lib relative Failed Running automake! Failed Running automake! ldapsearch scandinavian characters #suse Can't locate object method finsh #linux xorg-7 + tgz #lisp
|
|