2

I want to replace the string America/Adak with America/Jamaica by:

       perl -i -pe "s/$A/$B/"  /etc/sysconfig/clock 

please advice what need to update in the perl syntax ? ( the problem is that I have "/" so need to ignore this uniq character , what need to add to my perl syntax?

 A="America/Adak"
 B="America/Jamaica"
 CLOCK=/etc/sysconfig/clock

 perl -i -pe "s/$A/$B/" $CLOCK

 Bareword found where operator expected at -e line 1, near "s/America/Adak/America"
 syntax error at -e line 1, near "s/America/Adak/America"
 Execution of -e aborted due to compilation errors.

 more $CLOCK
 # The ZONE parameter is only evaluated by system-config-date.
 # The timezone of the system is defined by the contents of /etc/localtime.
 ZONE="America/Adak"
 UTC=true
 ARC=false
Diana
  • 261

1 Answers1

5

Use a different delimiter, for example:

perl -i -pe "s|$A|$B|" $CLOCK

See the perlre man page.