Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

up vote 3 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

Your Answer

 
discard

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.