I have the following prompts
[/share/registrazioni/Script] # cat delete_7gg.sh
#!/bin/sh
find /share/registrazioni/ -type f -mtime +7 -delete
[/share/registrazioni/Script] # which sh
/bin/sh
[/share/registrazioni/Script] # chmod +x delete_7gg.sh
[/share/registrazioni/Script] # ./delete_7gg.sh
-sh: ./delete_7gg.sh: /bin/sh^M: bad interpreter: No such file or directory
why do I get /bin/sh^M: bad interpreter: No such file or directory ? I made the script with vi. I made the script in a qnap qts 4.3.6 that I can reach via ssh. The script should simply delete files older than seven days. I can't install dos2unix because the system has no package manager. I just expected to make a script and put it into cron. but I'm receiving that error instead.
vi
, you can change between line endings using:set ff=unix
and:set ff=dos
– steeldriver Apr 16 '19 at 12:54^M
What is^M
and how do I get rid of it?, Unix script appends ^M at end of each line, -bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory... – phuclv Apr 16 '19 at 15:53dos2unix
. – Kusalananda Oct 28 '19 at 15:05