On 21:27 14 Jan 2003, Bret Hughes <[EMAIL PROTECTED]> wrote: | On Tue, 2003-01-14 at 20:50, Cameron Simpson wrote: | > It separates selection from operation. It says, "globally, for all lines | > containing abdfggg, substitute that (// being 'that') with opsmsdd". | > | > You can do more flexible things, like: | > | > g/foo/ .-2,.+2m0 | > or | > g/bah/ s/this/that/g | > | | If I understand correctly, your last example says for the entire file | look for lines that have bah, and if they do, subsitute all occurances | of this with that
Exactly so. | Am I close? this is more flexible than trying to build a regex that | would do the same thing in the syntax I have used in the past. I never | have sucessfully atomized letter combinations so I can use ? as a | conditional. At least I don't think I have but I remember trying. | | I remember trying something like (from memory only) | | %s/({bah.*}?)(this)({.*bah}?)/$1that$3/g That'd do every line because the "...bah...?" is optional, so even lines with no bah will match. | the g/foo/ one I am going to have to read up on before beginning to ask | a question about it :) Thinks of it like a pre-grep for the target lines. Of course, that's what grep comes from you know: g/re/p where "re" means regular expression. So it came straight out of ed. Cheers, -- Cameron Simpson, DoD#743 [EMAIL PROTECTED] http://www.zip.com.au/~cs/ That said, I'm inclined to agree that that's not necessarily a good idea. I always wanted to write a little program that would pop up a Mac window to ask ``I'm going to amputate a limb at random from you now.'' to see how many people would instinctively click "OK". - Marc VanHeyningen <[EMAIL PROTECTED]> -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list