Search code examples
bashunixterminalbin

bin bash bad interpreter


#! bin/bash
mkdir ~/folder
while [ $brojac -le 5]
do
mkdir ~/folder/zad"$brojac"
brojac = $(( brojac+1 ))
done

this is my shellscript,but when I want to run it in terminal, I receive this error

mint@mint ~ $ ./prvi.sh
bash: ./prvi.sh: bin/bash: bad interpreter: No such file or directory
mint@mint ~ $ 

Solution

  • Small errors in your script:

    1. $brojac is unassigned, so your integer comparison fails. Assign it an initial value to fix.
    2. '[' calls test, so you need spaces around opening and closing braces.
    3. You can't have spaces around your equal sign when assigning a value.

    Your script, updated:

    #!/bin/bash
    mkdir ~/folder
    brojac=0
    while [ $brojac -le 5 ]
    do
        mkdir ~/folder/zad"$brojac"
        brojac=$(( brojac+1 ))
    done