Troubleshooting of bash script: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Resolving Common Bash Script Execution Errors __TOC__ == Common Bash Script Execution Errors == === How to fix Permission Denied Error: "unable to execute" === '''Error description:''' <pre> $ ./bash-script.sh unable to execute ./bash-script.sh: No such file or directory </pre> '''Resolution:''' Add execute permissions to the script using: <pre> $ chmod +x bash-script.sh </pre> === How to fix Line Ending Compatibility Error === '''Problem:''' <pre> $ ./bash-script.s...") |
(No difference)
|
Revision as of 14:18, 17 January 2025
Resolving Common Bash Script Execution Errors
Common Bash Script Execution Errors
How to fix Permission Denied Error: "unable to execute"
Error description:
$ ./bash-script.sh unable to execute ./bash-script.sh: No such file or directory
Resolution: Add execute permissions to the script using:
$ chmod +x bash-script.sh
How to fix Line Ending Compatibility Error
Problem:
$ ./bash-script.sh -bash: ./bash-script.sh: /bin/bash^M: bad interpreter: No such file or directory
Resolution: Convert Windows line endings (CRLF) to Unix format (LF):
$ sed -i 's/\r$//' bash-script.sh
This error typically occurs when a script is created on Windows and transferred to a Unix/Linux system. The sed command removes the Windows carriage return characters (\r) that cause the interpreter error.