I want to add the PATH - /usr/local/bin/perl befpore string in the file by perl command line ( the perl command line must be in my bash script ) , I have solaris machine
the target to add - /usr/local/bin/perl before the line $APIDIR/scan.pl in the file and after the char - "
please advice how to add the PATH - /usr/local/bin/perl before $APIDIR/scan.pl so finally I will get
the new line's -
my $APIDIR="/usr/local/cp/api"; remark - this line shouldn’t be change
my $script="/usr/local/bin/perl $APIDIR/scan.pl";
in place of
my $APIDIR="/usr/local/cp/api";
my $script="$APIDIR/scan.pl";
I try the following but its not change the line:
[root@machine1a /var/tmp]# perl -p -i -e 's/\/usr\/local\/bin\/perl \$APIDIR\/scan.pl/\$APIDIR\/scan.pl/g' file
[root@machine1a /var/tmp]# more file
my $APIDIR="/usr/local/cp/api";
my $script="$APIDIR/scan.pl";
You can do this with sed e.g.
or with perl
So you want to replace $APIDIR with /usr/local/bin/perl $APIDIR ? If so, your regex is backward. You want something like:
So try:
I hope this is what you were after-