Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling "perl -ipe" inside a UNIX Korn Shell Script 1

Status
Not open for further replies.

Ditter

Programmer
Sep 11, 2000
16
0
0
FR
Hi:

I've been trying to use perl -ipe inside a Korn Shell Script top perform substitutions. A sample code is:

...
CRITERIA="'s/$SEARCH_STRING/$REPLACE_STRING/g'"
...
/usr/bin/perl -ipe $CRITERIA $FILE
...

Where:
$SEARCH_STRING is a korn shell var that I've created to
store dynamic search criteria strings.

$REPLACE_STRING is the substitution string.

$FILE is the file where the substitutions will be performed.

===================
PROBLEM:
===================
PERL call is not translating properly shell variables.
I've also tried:

/usr/bin/perl -ipe "$CRITERIA" $FILE
/usr/bin/perl -ipe \$CRITERIA $FILE

And it doesn't work. What's wrong???

 
Remove single quote from CRITERIA definition :
[tt]
...
CRITERIA="s/$SEARCH_STRING/$REPLACE_STRING/g"
...
/usr/bin/perl -p -i -e $CRITERIA $FILE
...
[/tt]

Jean Pierre.
 
Thank yoy very much!!! Now it works fine. =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top