有一个shell脚本,每次我在服务器上运行两次时,它会多次询问是否选择“是/否”,几乎要100次。我已经厌倦了每次都输入“是”。有没有办法运行该脚本时将“是”作为默认选项?以下是我的脚本!请注意,我不能编辑我的脚本。只能使用./ittp-update.sh
来运行它。
#!/bin/bash
echo "Do you need to install the necessary compiling tools?"
select yn in "Yes" "No"; do
case $yn in
Yes ) sudo apt-get install tools; break;;
No ) <Here I want to skip to the next step. I originally left it
blank and removed the "done" command (after esac command)
to do this, but if I choose yes, it skips to the end
(where the next "done" command is and ends the script>
esac
echo "Do you need to eidt your configuration?"
select ny in "No" "Yes"; do
case $ny in
No ) <what do I put here to skip to the next tag
(labeled compile for example purposes); break;;
Yes )
esac
echo "You have 3 options with how you can edit you config file."
....
yes | ./ittp-update.sh
将回答所有问题(通过连续输入yes
和换行符)。 - Biffen