我正在编写脚本,但不断收到此错误语法错误:“)”意外(预期“;;”)
这是脚本
#!/bin/sh
#Name:gamer
#Date Created: 12/6/2015
#last modified: 12/8/2015
#Desc/Purpose: Updating and installing apps.
DATE=$(date -d "$1" +"%m_%d_%Y");
condition=y
while [ $condition = "y" ] || [ $condition = "Y" ]
do
clear
echo -n "Do you know how to Update OS"
read answer
if [ $answer = "y" ] || [ $answer = "Y" ]; then
echo "Good update the os then."
elif [ $answer = "n" ]; then
echo "would you like me to update it for you"
read response
if [ $response = "y" ]; then
echo "updating os!"
sudo apt-get update os
clear
echo -n "which app would you like to install"
read answer
if [ $answer = "y" ] || [ $answer = "Y" ]; then
echo "A) Install Webmin"
echo "B) Install Apache"
echo "C) Install gnome shell"
echo "D) get ubuntu desktop"
echo "E) Add new user"
echo "F) get Xubuntu Desktop"
echo "G) Install openbox"
echo "H) remove Libre office"
echo "I) I don't want to install anything"
read option
case $option in
A) sudo apt-get install webmin ;;
B) sudo apt-get install apache ;;
C) sudo apt-get install gnome-shell ;;
D) sudo apt-get install ubuntu-desktop ;;
E) sudo useradd ;;
F) sudo apt-get install xubuntu-desktop ;;
G) sudo apt-get install openbox ;;
H) sudo apt-get remove --purge libreoffice* ;;
I) echo "You can always do it later"
*) echo "Please select one of the options"
done
非常感谢所有帮助,谢谢。
答案1
正确的:
#!/bin/sh
#Name:gamer
#Date Created: 12/6/2015
#last modified: 12/8/2015
#Desc/Purpose: Updating and installing apps.
DATE=$(date -d "$1" +"%m_%d_%Y");
condition=y
while [ $condition = "y" ] || [ $condition = "Y" ]
do
clear
echo -n "Do you know how to Update OS"
read answer
if [ $answer = "y" ] || [ $answer = "Y" ]; then
echo "Good update the os then."
elif [ $answer = "n" ]; then
echo "would you like me to update it for you"
read response
if [ $response = "y" ]; then
echo "updating os!"
sudo apt-get update os
fi
fi
clear
echo -n "which app would you like to install"
read answer
if [ $answer = "y" ] || [ $answer = "Y" ]; then
echo "A) Install Webmin"
echo "B) Install Apache"
echo "C) Install gnome shell"
echo "D) get ubuntu desktop"
echo "E) Add new user"
echo "F) get Xubuntu Desktop"
echo "G) Install openbox"
echo "H) remove Libre office"
echo "I) I don't want to install anything"
read option
case $option in
A) sudo apt-get install webmin ;;
B) sudo apt-get install apache ;;
C) sudo apt-get install gnome-shell ;;
D) sudo apt-get install ubuntu-desktop ;;
E) sudo useradd ;;
F) sudo apt-get install xubuntu-desktop ;;
G) sudo apt-get install openbox ;;
H) sudo apt-get remove --purge libreoffice* ;;
I) echo "You can always do it later" ;;
*) echo "Please select one of the options" ;;
sac
fi
done