Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Exec format error on bash script

📅 2021-Apr-07 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ bash, error ⬩ 📚 Archive


I had a few repetitive commands that I pasted into a text file and created a Bash script from it. I made the script file executable. When I ran the script, I got this error:

$ ./
Failed to execute process './'. Reason:
exec: Exec format error
The file './' is marked as an executable but could not be run by the operating system.


The Bash script file was so small and simple that this error stumped me for a moment.

On closer examination, I found that I had mistakenly put a space before the shebang and that was throwing this error:

^-- space


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧