shell script: bad interpreter: No such file or directory when using pwd

后端 未结 11 1766
抹茶落季
抹茶落季 2021-02-07 09:30

I want to go through the files in a directory with a for loop but this comes up.

echo: bad interpreter: No such file or directory

code:

11条回答
  •  南旧
    南旧 (楼主)
    2021-02-07 10:07

    In my case the bash script was created on a Windows PC which added a carriage return character in front of every line feed. \x0D\x0A instead of just \x0A. I replaced all the CRLF with just LF using the sed and my script works now.

    sed -i 's//\r/\n//\n/g' /path/to/file.sh
    

提交回复
热议问题