0

I am trying to execute the below command from a shell script: perl -pi -e 's/Ç/|/g' diff_new_old.dat This command gets executed without any errors, but the execution doesn't do the intended substitution. It doesn't seem like shell has an issue with execution of perl command, since perl -pi -e 's/\n/\r\n/g' diff_new_old.dat works fine. It looks like an issue with special character substitution.

When I execute the same command directly on $ prompt, it executes fine and substitutes all Ç characters with | in the file. I want to automate this process and thus need a way to get this done from a shell script.

I have also tried using the sed 's/Ç/|/' command. But this results into below error: sed: -e expression #1, char 6: unterminated `s' command

Please let me know what I can do to achieve the substitution.

Thanks in advance.

1 Answer 1

2

You may have to tell perl that the script contains UTF-8 characters:

perl -Mutf8 -pi -e 's/Ç/|/g' diff_new_old.dat

see http://perldoc.perl.org/utf8.html

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .