Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


 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.
share|improve this question
up vote 5 down vote accepted

Use a different delimiter, for example:

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

See the perlre man page.

share|improve this answer
well done !!!!!!!!!!!!!!! – Diana Nov 17 '11 at 16:14
You can use most special characters as delimiters in perl and in sed. – Bruno9779 Apr 17 '15 at 1:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.