| |
| |
| |
|
Page: 1 2
Comments:
<0> where can i find the exact syntax for what chars are escaped vs non-escaped in sed regex? <1> it's plain BRE syntax. you can find it everywhere <1> don't mix it up with ERE, it's different <2> PCRE ! <1> and don't get confused by GNU sed interpreting \+ in BRE - that's GNU, not BRE ;) <3> strange thing, theres a file where i did s/aa$/laalaaa/ and the file actually shrinked in file size.. <0> kaneuneu, so how do i figure out what regex my sed supports? <0> hahah, talkin to myself :) <3> :) <4> kaneuneu: sed --version <2> it support BRE by default <0> goldfish, yes i know that <0> goldfish, i read the faq <0> and i read the link to the BRE documentation including the ERE documentation <0> GNU sed version 4.1.5 <2> ok.
<5> kaneuneu: Are you escaping the contents of a shell variable for use in a pattern? <0> not that i know of why <0> i'm doing search/replace in multiple files with bash/find/sed on the command line <0> i just wanted to know the exact syntax of regex's in sed <0> or at least in my version <5> man sed I suppose. :) <5> or info sed or http://www.opengroup.org/onlinepubs/009695399/utilities/sed.html <0> um, man sed not so much <2> kaneuneu: http://wooledge.org/mywiki/BashFaq#faq21 -- How can I replace a string with another string in all files? <2> might also help you. <5> BRE is simple. ^ is special at the beginning of a pattern, $ is special at the end. dot . star * and bracket [ are special, and backslash is special. <5> That's it <5> Actually, * is not special if it is the first character of a (sub) expression. <5> And the rules inside [] are different. <6> grep -Rh blah . | sed -e 's/(.*)/\1/g' <6> sed: -e expression #1, char 11: invalid reference \1 on `s' command's RHS <6> this is just a simple case..does someone see what's wrong w/ the syntax? <7> aib: are you sure the grep part outputs anything? <7> usually what sed says there means that it didnt match anything, it doesnt have a \1 becuase it didnt match anything. <6> grep won't always output anything. ok <2> aib: sed -e 's/\(.*\)/\1/g' <2> although <2> that's a pretty useless command. <6> yeah it's not what i'm doing, same idea tho =) <7> i thought -e in this example was "use extended regex" :) <2> nope. <2> -e script, --expression=script <2> add the script to the commands to be executed <2> -r, --regexp-extended <2> use extended regular expressions in the script. <7> in freebsd -E is extended re :) <2> you could also use, s/.*/&/g <7> aib: did it work out though? <6> not yet <2> what's the problem? <7> i think his command line or grep comman disnt performing. he will have to spank it really hard to get some out of it >_< <6> echo blah | sed 's/()/\1/' reproduces it...wonder why this is happening <8> aib: like goldfish said you have to use \( and \) if you want to back reference things <8> (if you use the 'defualt' RE) <6> ahh <7> thats true <6> sorry i missed that suggestion <6> works=) <7> heh <7> or use -r for extended regex <7> or is that not preferred by the sed community? =) <7> just asking ^^ <2> Probably not. <2> Who cares :) <7> hehe <6> it works but it's pretty quirky. in the actual RE it won't allow me to do it w/ -r, have to escape <7> hm <7> echo blah | sed -E 's/()/\1/' => blah <7> (-E equal to -r) <1> rawtaz_: the keyword is not "community", it's "standard software" ;) <7> =) <9> does command D act like a loop in sed? <9> in certain cases <9> what is the meaning of empty regular expression? <9> // <9> match previous regex?
<9> or match previous matched regex <7> no <7> matches nothing <9> then why does sed give this error: <9> sed: -e expression #1, char 0: No previous regular expression <9> on an expression sed -n '// p' <9> i am trying to understand what it does <2> // is a line address <9> and which address does it match? <2> it doesn't match any, afaik <9> I am trying to demistify this sed expression: sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//' <9> which reverses the lines <9> acts like `rev' <2> read http://www.grymoire.com/Unix/Sed.html#uh-0 <9> I know all the sed commands etc. <2> hm, ok. <9> i know sed very good <9> but it is hard to understand this one <9> because of the //D command <2> where did you get teh command from? <9> i am going through all the sed one liners <9> http://sed.sourceforge.net/sed1line.txt <9> or http://www.pement.org/sed/sed1line.txt <9> to boost my skills of sed a little more <9> and came accross that one which is difficult to grasp <9> can anyone explain it to me? <2> I bet prec can. <9> prec, you there? <2> I haven't played with G or D, i'm afraid. <9> oh, they are very easy, read http://www.grymoire.com/Unix/Sed.html#uh-0 <9> :) <2> :) <9> G appends whatever is in hold space to pattern space <9> in this case it is always new line <9> and D deletes everything from pattern space up until \n <9> i remember there were examples of commands <9> and maybe there was this one <9> any sed guru in here? <7> pkrumins: how will you know unless you ask them a question which wil reveal their true skillz? ;) <7> (hint: im not the one, though) <9> I am trying to demistify this sed expression: sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//' <9> what it does it acts as `rev' <7> ooh that one. <9> yes, the same one <7> i have no idea really, but if i were to give it a shot, id start with "for each line" (since it matches first on \n). then something.. :) <9> misteriously it doesnt match first on \n <9> echo "test" | sed -n '/\n/ p' <9> does not print anything <10> I believe it will always execute G? <7> its an interesting line <10> hmm... although <9> iSteve, I am not sure <10> pkrumins: G will append <9> i know all the commands, iSteve <10> pkrumins: so if you get two lines, you get a metch <10> match <10> yea yea you said that <9> tell me about //D <10> and do you hear me arguing? <10> //D keeps me confused <10> it shouldn't work:) <9> now i hear you arguing <9> iSteve, what about echo "test" | sed -n '/\n/ p' <9> why doesnt it print <10> you heard me arguing? now you hear me saying 'good luck with your problem' <9> okay, thanks <7> sed is really interesting <7> so is awk <9> if /\n/ matched then the test example should have printed <11> iSteve: '//D' is supposed to take the last matched pattern ('//') and delete thing to a first new line starting a new cycle with the rest of pattern space ('D')
Return to
#sed or Go to some related
logs:
amount of cafeine in tea +preseed +partman +primary partitions #linux ktorrent 2gb 1684370019 emarge command not found isgenerator type python ubuntu iproute2 ifconfig deprecated Invalid object definition type 'hostextinfo' #suse
|
|