what is the unix command line search and replace tool using regex? here is an example of what I am trying to do: replace the % in "1.01.%" with * to make it "1.01.*" or to change "%1.345%%" to "*1.345**". This way I can write a script to locate all core files, pipe the output to a replacer that will generate rm commands to delete the files. ps. I am only using core files as an example. I am aware of yasts/suseconfig abilities to delete core files automatically. TIA Adi. -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
Adi Gadwale wrote:
what is the unix command line search and replace tool using regex?
here is an example of what I am trying to do:
replace the % in "1.01.%" with * to make it "1.01.*" or to change "%1.345%%" to "*1.345**". This way I can write a script to locate all core files, pipe the output to a replacer that will generate rm commands to delete the files.
Try a c program called streplace. http://www.ibiblio.org/pub/Linux/utils/scripts/streplace-0.9.16.lsm http://www.ibiblio.org/pub/Linux/utils/scripts/streplace-0.9.16.tar.gz -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
On Fri, 15 Sep 2000 14:21:39 -0500 (CDT), Adi Gadwale wrote: | | what is the unix command line search and replace tool using regex? | | here is an example of what I am trying to do: | | replace the % in "1.01.%" with * to make it "1.01.*" | or to change "%1.345%%" to "*1.345**". Learn Perl! It's full of little wonders and miracles! perl -pi -e 's/%/*/g' foo If you drop 'foo' it will read from STDIN and you can type from the keyboard to see what it does in advance. It will replace any string with any other string depending on any (dynamic!) criterium you wish. Koos Pol ---------------------------------------------------------------------- S.C. Pol T: +31 20 3116122 Systems Administrator F: +31 20 3116200 Compuware Europe B.V. E: koos_pol@nl.compuware.com Amsterdam PGP public key available -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
Is it possible to do this same thing in Python? Regards, Adi. On 18 Sep 2000, Koos Pol wrote:
On Fri, 15 Sep 2000 14:21:39 -0500 (CDT), Adi Gadwale wrote:
| | what is the unix command line search and replace tool using regex? | | here is an example of what I am trying to do: | | replace the % in "1.01.%" with * to make it "1.01.*" | or to change "%1.345%%" to "*1.345**".
Learn Perl! It's full of little wonders and miracles!
perl -pi -e 's/%/*/g' foo
If you drop 'foo' it will read from STDIN and you can type from the keyboard to see what it does in advance. It will replace any string with any other string depending on any (dynamic!) criterium you wish.
Koos Pol ---------------------------------------------------------------------- S.C. Pol T: +31 20 3116122 Systems Administrator F: +31 20 3116200 Compuware Europe B.V. E: koos_pol@nl.compuware.com Amsterdam PGP public key available
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
On Mon, 18 Sep 2000 08:05:40 -0500 (CDT), Adi Gadwale wrote: | | Is it possible to do this same thing in Python? | | | Regards, | | > | > | | > | what is the unix command line search and replace tool using regex? | > | | > | here is an example of what I am trying to do: | > | | > | replace the % in "1.01.%" with * to make it "1.01.*" | > | or to change "%1.345%%" to "*1.345**". | > | > Learn Perl! It's full of little wonders and miracles! | > | > perl -pi -e 's/%/*/g' foo | > | > If you drop 'foo' it will read from STDIN and you can type from the keyboard | > to see what it does in advance. It will replace any string with any other | > string depending on any (dynamic!) criterium you wish. | > I don't know. But I really doesn't get any easier and simpler and more powerfull that with perl, does it? Are you having difficulties? BTW, you are quoting at the wrong side of the original posting. Cheers Koos Pol ---------------------------------------------------------------------- S.C. Pol T: +31 20 3116122 Systems Administrator F: +31 20 3116200 Compuware Europe B.V. E: koos_pol@nl.compuware.com Amsterdam PGP public key available -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
On 18 Sep 2000, Koos Pol wrote:
On Fri, 15 Sep 2000 14:21:39 -0500 (CDT), Adi Gadwale wrote:
| | what is the unix command line search and replace tool using regex? | | here is an example of what I am trying to do: | | replace the % in "1.01.%" with * to make it "1.01.*" | or to change "%1.345%%" to "*1.345**".
Learn Perl! It's full of little wonders and miracles!
perl -pi -e 's/%/*/g' foo
If you drop 'foo' it will read from STDIN and you can type from the keyboard to see what it does in advance. It will replace any string with any other string depending on any (dynamic!) criterium you wish.
You are definately right that Perl is great, but in this particular situation, sed might be the best tool. The command is ed -e 's/%/*/g' foo or without the foo to read from STDIN just like the Perl example. The reason, I think sed is better than Perl for this, is the simple fact that sed is a much smaller program. Perl would be overkill. Regards Ole -- Windows: Where do you want to go today? MacOS: Where do you want to be tomorrow? Linux: Are you coming or what? -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
participants (4)
-
adi@gadwale.com
-
koos_pol@nl.compuware.com
-
okh-linux@post.cybercity.dk
-
zentara@gypsyfarm.com