-1

./menu: line 12: [1: command not found

This thing keeps showing up even though doesn't affect script's functionality.

Script:

#!/bin/bash/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/rvs130@studin.aubgin.$

function press_enter
{
    echo ""
    echo -n "Press Enter to continue"
    read
    clear
}

choice=
until ["$choice" = "0"]; do
        echo ''
        echo '          SMILEY SERVER MENU'
        echo '1 - To view the available smilies'
        echo '2 - Search for a smiley'
        echo '3 - Add a new smiley'
        echo '4 - Delete a smiley'
        echo '5 - Edit smiley or description'
        echo ''
        echo '0 - Exit'
        echo 'Enter your choice: '
        read choice

        case "$choice" in
                1)
                cat smilies.txt;;
                2)
                echo 'Please enter the name of the smiley you want to see: '
                read name
                echo 'Match found: '
                grep $name smilies.txt ;;
                3)
                echo 'Enter the smiley you want to add followed'
                echo 'by a space and description: '
                read newsmiley
                echo "$newsmiley" >> smilies.txt
                echo 'New smiley added.' ;;
                4)
                echo 'Enter a smiley or its description you want to delete: '
                read delsmiley
                sed -i /"$delsmiley"/d smilies.txt ;;
                5)
                echo 'Enter a word you want to edit, space'
                echo 'and then desired replacement word: '
                read word1 word2
                replace "$word1" "$word2" -- smilies.txt ;;
                0) exit ;;
                *)
                echo 'Please enter a valid choice.'; press_enter
        esac
done
l0b0
  • 55,365
  • 30
  • 138
  • 223
  • possible duplicate of ["Command not found" when attempting integer equality in bash](http://stackoverflow.com/questions/4468824/command-not-found-when-attempting-integer-equality-in-bash) – tripleee Nov 29 '14 at 12:30

1 Answers1

1

You must have spaces around [ and ]. What happens in your script is that the first time round, $choice is empty, so the line evaluates to [ = "0"], which should result in an error like bash: [: missing `]' the first time round (which, unless you set -o errexit, will not affect execution). After choosing 1 and coming round to the test line again, it evaluates to [1 = "0"], where [1 is interpreted as the command you want to run. What you want is:

until [ "$choice" -eq 0 ]

Also, that's not a valid shebang line.

l0b0
  • 55,365
  • 30
  • 138
  • 223