On Dec 1, 2003, at 3:41 AM, Manish Uskaikar wrote:


I want to do a simple search replace on a unix command prompt.
What i require is a syntax to do is?
echo "I am Manish"|<perl command>
output     I am Jeff.

jeff,


I am drieux.
What I would recommend is something old school,
in which you go with something like code:


#!/usr/bin/perl -w use strict; my ($find, $replace) = @ARGV; while(<STDIN>) { $_ =~ s/$find/$replace/; print $_; }

then you can do:

[jeeves: 22:] echo "I am Manish" | ./simple_filter Manish Boyish
I am Boyish
[jeeves: 23:]

if you then put your script in one of the directories
which are in you PATH, as I do with my $HOME/bin,
then it will be findable.

As you want to 'grow it out' to handle the
error cases such as not having enough arguments,
and more and more complex RegEx, then you can
style it as you like.

HTH.

ciao
drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to