7행: [:missing `]' 이 오류가 발생합니다. 어떻게 해결합니까? 들여쓰기했어요 [복제]

7행: [:missing `]' 이 오류가 발생합니다. 어떻게 해결합니까? 들여쓰기했어요 [복제]
#!/bin/bash

until ["$userIn" = "j"]

      do
          echo "Welcome to the Menu_Script Program!"
          echo 
          echo "Menu Options"
          echo "Please Select an Option."
          echo 
          echo 
          echo "Press a to use the Emailer Program"
          echo 
          echo "Press b to Display the Users that are Currently Logged On"
          echo 
          echo "Press c to Display the Current Date and Time"
          echo 
          echo "Press d to Display the Months Calendar"
          echo 
          echo "Press e to Display the name of the Working Directory"
          echo 
          echo "Press f to Display the Contents of the Working Directory"
          echo 
          echo "Press g to Find the IP of a Web Address"
          echo 
          echo "Press h to See your Fortune"
          echo 
          echo "Press i to Display a file on the screen"
          echo 
          echo 
          echo "Press j to Exit this Menu"
          echo 
          echo "Press m to show the Menu Options again"
          echo 

          read mOption

          case "$mOption" in

               a|A)
                   echo "Welcome to the Emailer Program"
                   echo 
                   echo "Please enter the content of your message and press <ENTER>:"
                   read $mContent
                   echo 
                   echo "Please enter the email address of the recipient and press <ENTER>:"
                   read $mAddress
                   echo 
                   echo "Is there a file to be attached to this message? Press Y/N:"
                   read $ATTACH
                   echo 

if ["$ATTACH"="Y"|"y"]
                   then
                       echo "Please enter the name of the FILE to be attached:"
                       read $mAttach
                       mail -s "$mContent" "$mAddress"<"$mAttach"
                       echo 
                       echo "Your mail will be sent with the attachment."
                       echo 

                   else
                       mail -s "$mContent""$mAddress"
                       echo
                       echo "Your mail will be sent without an attachment."
                       echo 
                   fi
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               b|B)
                   echo "Here is a list of users that are currently logged on:"
                   w
                   echo 
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               c|B)
                   echo "The current date and time:"
                   date
                   echo 
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               d|D)
                   echo "Here is the current Months of the calendar:"
                   cal
                   echo
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               e|E)
                   echo "Here is the name of the Working Directory:"
                   pwd
                   echo 
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               f|F)
                   echo "Here is the Contents of the Working Directory"
                   ls
                   echo 
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               g|G)
                   echo "Please type a Web Address whose IP Address you"
                   echo "would like to find, then press <ENTER>:"
                   read $mWeb
                   echo 
                   echo "Here is the IP Address Information:"
                   nslookup $mWeb
                   echo 
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               h|H)
                   echo "Here is your Fortune for today!"
                   echo 
                   fortune
                   echo 
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               i|I)
                   echo "Please enter the name of the file that you want to be displayed:"
                   read $mFile
                   echo 
                   echo "Here is your file:"
                   cat $mFile
                   echo 
                   echo "Select a new Option, press j to Exit or m to show the Menu Options:"
                   echo 
                   ;;

               j|J)
                   echo "Thank you for using the Menu_Script Program!"
                   userIn = j
                   echo
                   ;;


               m|M)
                   echo "Menu Options"
                   echo "Please Select an Option:"
                   echo 
                   echo
                   echo "Press a to use the Emailer Program"
                   echo 
                   echo "Press b to Display the Users that are Currently Logged On"
                   echo 
                   echo "Press c to Display the Current Date and Time"
                   echo 
                   echo "Press d to Display the Months Calendar"
                   echo
                   echo "Press e to Display the name of the Working Directory"
                   echo 
                   echo "Press f to Display the Contents of the Working Directory"
                   echo 
                   echo "Press g to Find the IP of a Web Address"
                   echo 
                   echo "Press h to See your Fortune"
                   echo 
                   echo "Press i to Display a file on the screen"
                   echo 
                   echo 
                   echo "Press j to Exit this Menu"
                   echo 
                   echo "Press m to show the Menu Options again"
                   echo 
                   ;;
               *)
                   echo "Invalid Selection."
                   echo "Select a valid option, press j to Exit or m to show the Menu Options"
                   ;;

        esac
done

답변1

[명령이다.
따라서 다른 명령과 마찬가지로 매개변수 뒤에 공백을 추가하여 처리해야 합니다.
노력하다 man [. 터미널에 이것을 입력하면
오류 와 동일한 내용을 나타내는 명시적으로 명명된 바이너리/명령이 없으면 작동하지 않습니다.echofooechofooechofoo: command not found.

답변2

여는 괄호 뒤에 공백 기호를 추가하고 닫는 괄호 앞에 공백을 추가해야 합니다. 이 줄은:

if ["$ATTACH"="Y"|"y"]

되기 (여러 기호 사용)

if [[ $ATTACH == [Yy] ]]

동일

until ["$userIn" = "j"]

~이 되다

until [ "$userIn" = "j" ]

관련 정보