Why am I getting “: No such file or directory” when trying to execute a bash script?

I’m trying to execute a bash script (git-ftp) but I can’t seem to do it. This is what happens:

[trusktr@rocketship ~]$ ~/scripts/git-ftp
: No such file or directory

The file has permissions 755.

This is the contents of the script: http://pastie.org/3567556

Why am I getting this error? What can I do to fix the problem?

  • pipe is returning empty string in bash in git for windows
  • Compare with diff and format the output
  • Provide passphrase to git in bash script
  • Shell script works fine by itself, but produces unexpected results when run through git filter-branch
  • Git shell command alias giving a “bad config file” error
  • Automate vi / nano editor for git commit --amend
  • Git: unable to redirect/parse the output of 'git fetch --dry-run' command
  • How do I write a batch file which opens the GitBash shell and runs a command in the shell?
  • 2 Solutions collect form web for “Why am I getting “: No such file or directory” when trying to execute a bash script?”

    I have seen this error if the script has windows line endings instead of unix line endings. Try running dos2unix on the script and see if you get the same error.

    Is there a #! (hash bang) line in the script, and does the pathname resolve?

    If the script is running, it may be something in the script. Add this command to the top of the script, before any other command (but of course after the hash bang, if there is one):

    set -x   # enable trace mode
    
    Git Baby is a git and github fan, let's start git clone.