Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm new to bash and can't seem to get it to compile some C code without annoying messages. I'm quote sure it's the semicolons because if I remove or change them at all it will pretty much break. The warnings/errors I get are ": not found: :" with nothing else repeatedly for every line. Any help is appreciated.

GCC=/usr/bin/gcc ;
INSERTS="10000 20000 50000 100000 150000 250000 375000 500000 750000 1000000"
#compile with options
$GCC -DDEBUG -o codetest $CODESRC;
#run with parameters
./codetest $INSERTS;


The code compiles and runs fine. If I remove all the semicolons and try to run it using sh test.sh I get the following.

test.sh: 6: /usr/bin/gcc
: not found
test.sh: 8: ./codetest: not found

edit: Ahh, silly me; it was a windows/unix line endings problem, became apparent when running ./test.sh and getting /bin/bash^M: bad interpreter

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The semicolons shouldn't be necessary, but other than that the script looks ok.

  • Can you be more specific about the errors you're getting?
  • Does the code compile and run correctly when you try it outside of the script?
  • How are you running the script?


  • As that definitely the location of gcc? What is the output of which gcc
  • Are you running the script from the same directory as your code?
  • Since your script specifies that it should be ran with /bin/bash you should run it as ./test.sh, not sh test.sh
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.