このcase
文を使用してパラメータを処理できますか?したがって、-restartを使用して「-umount」と「-mount」を実行したいと思います。
#!/bin/bash
case "$1" in
-mount
mount /ip/share1 /local/share1
;;
-umount
umount /ip/share1
;;
-restart
# echo TODO
;;
*)
[...]
esac
ベストアンサー1
)
sが欠落している構文の問題を除いて、これはうまくいくようです。これをテストしましたが、正しく動作します..
#/bin/bash
case "$1" in
"-mount")
mount /path/to/device /path/to/mountpoint
;;
"-unmount")
umount /path/to/mountpoint
;;
"-remount")
"$0" -unmount
"$0" -mount
;;
*)
echo "You have failed to specify what to do correctly."
exit 1
;;
esac