-1
大学の割り当てのためのカスタムシェルスクリプトの作成。実際にはこれとは別にすべての作業があります。 functionIfcという関数を呼び出すifcというエイリアスがあります。ただし、このコードを使用すると、予期しないトークン '}'が見つかったことがわかります。これをデバッグできないようです。しばらくそれに固執していた。どんな助けでも大歓迎です!Bashスクリプト機能
alias ifc="functionIfc";
functionIfc(){
echo "Please enter which ethernet you would like to display"
echo -e "\n Command ifc1: Shows loopback"
echo -e "\n Command ifc2: Shows eth 0"
echo -e "\n Command ifc3 Shows eth 1"
echo -e "\n Command ifc4 shows eth 2"
echo -e "\n Command ifc5 shows eth 3"
read INPUT
if [ $(INPUT) == "ifc1" ]; then
echo $(ip addr show lo)
else if [ $(INPUT) == "ifc2" ]; then
echo $(ip addr show eth0)
else if [ $(INPUT) == "ifc3" ]; then
echo $(ip addr show eth1)
else if [ $(INPUT) == "ifc4" ]; then
echo $(ip addr show eth2)
else if [ $(INPUT) == "ifc5" ]; then
echo $(ip addr show eth3)
else
echo Not a valid entry, Try again
fi
}
バッシュ関数は()で宣言されていますか?おそらくスペースとafter()の間を使用してください... – Ko2r
http://www.shellcheck.net/のコードを文法チェックのために貼り付けることを検討してください。 [Here](http://stackoverflow.com/a/6212408/1983854)関数を定義する2つの方法を見ることができます。@ Ko2r – fedorqui