2

I have a file which has some russian chars in. Below is the content of by sh file.

#!/bin/sh
sed -i "s/\bVAR1\b/Привет, как ты/g" file1.txt

When i save this file i had to save this as UTF-8 or Unicode format as i have some Unicode format characters in the file and i will loose those if i save as ANSI. Once i save the file , when i use the file command i get the below

bash-4.1$ file test.sh
test.sh: UTF-8 Unicode (with BOM) English text, with very long lines, with CRLF line terminators

Question : how can I make this as executable shell script file? I get the below if my file has only English chars

bash-4.1$ file test2.sh
test2.sh: POSIX shell script text executable

Thanks in advance

  • I copied your script, with similar results, but when I corrected the first line, as @KamilMaciorowski indicates, then everything works fine. Indeed, it works without the correction (giving an error on the first line), despite the file output. – AFH Jan 5 at 16:47
  • Thanks for your comments. I got the script work. Had to avoid BOM chars and set fileformat=unix if the file was edited using any windows editor tools – Venkatesan Sundar Jan 5 at 23:17

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.