Bash Sh - Command Not Found [Duplicate]
#!/bin/bash
cd ~/workspace/trunk;
svn up;

When I run ./build.sh form command line, it says:

: command not found

And nothing happens. How can I solve this ?

0

I solved adding execute permissions:

sudo chmod +x file.sh

1

I Have resolved my error from this command.

sudo chmod +x build.sh

My guess is that you have unprintable control characters in the file, or it has \r\n (CRLF) line endings (dos/windows mode).

Try checking it with these commands:

$ hexdump -C build.sh 
00000000  23 21 2f 62 69 6e 2f 62  61 73 68 0a 63 64 20 7e  |#!/bin/bash.cd ~|
00000010  2f 77 6f 72 6b 73 70 61  63 65 2f 74 72 75 6e 6b  |/workspace/trunk|
00000020  3b 0a 73 76 6e 20 75 70  3b 0a                    |;.svn up;.|
0000002a

$ file build.sh 
build.sh: Bourne-Again shell script, ASCII text executable

$ unix2dos build.sh 
unix2dos: converting file build.sh to DOS format ...

$ hexdump -C build.sh 
00000000  23 21 2f 62 69 6e 2f 62  61 73 68 0d 0a 63 64 20  |#!/bin/bash..cd |
00000010  7e 2f 77 6f 72 6b 73 70  61 63 65 2f 74 72 75 6e  |~/workspace/trun|
00000020  6b 3b 0d 0a 73 76 6e 20  75 70 3b 0d 0a           |k;..svn up;..|
0000002d

$ file build.sh 
build.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators
2

Remove ; from the end of your script lines.

This doesn't happen in my bash, so I'm not sure what exactly is wrong, but my guess is this:

; is a separator of commands. Since your last command ends in ;, your bash probably expects another command after. Since the script finishes, though, it reads an empty command, which it can't execute.

5

None of the above worked for me except

sudo ./build.sh
Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest