私は入れ子になったifステートメントを持つスクリプトを作成しました。
if [ choice = "1" ]; then
if [ $package == *".tar.gz" ]; then //Could not find fi for this if
tar -zxvf folder.tar.gz
if [ $package == *".tar.bz2" ]; then
tar -xvfj folder.tar.bz2
./configure
make
make install
elif [ choice = "2" ]; then
dpkg -i package.deb
fi
//Expected fi
スクリプトでfiエラーが発生した場所を記録しました。
ベストアンサー1
以下は、使用したい一般的なケースですcase
。
case $choice in
(1)
case $package in
(*.tar.gz) tar -zxvf folder.tar.gz;;
(*.tar.bz2) tar -jxvf folder.tar.bz2;;
esac &&
./configure &&
make &&
make install
;;
(2)
dpkg -i package.deb
;;
esac