我有以下代码,其中包含一个 case 语句。
#!/bin/bash
ltfs=/usr/local/bin/ltfs
INDEX_FILE=/opt/LTO6_Extract/index.txt
sudo umount /mnt/ltfs
echo "Please push tape into drive and once the light stops flashing press ENTER"
read enterme
echo -n "Mounting the tape....."
sudo $ltfs -o devname=/dev/nst1 /mnt/ltfs
# We need the index file to get list and names of tape content
ls -R /mnt/ltfs/ | grep \.mxf$ > $INDEX_FILE
clear
PS3='Please enter your choice: '
readarray -t options < $INDEX_FILE
select opt in "${options[@]}"
do
IFS= read file <<< $opt
case $opt in
$opt) echo you have chosen $file ;;
esac
done
echo $file | sed 's/.mxf//g'
我的问题是,一旦从选项菜单中选择了一个文件,它随后不断要求我输入更多选择,但我只想输入一个然后执行后续命令(在这种情况下,后续命令位于底部(echo $file | sed 's/.mxf//g'
)。
我确定这很简单,但我似乎无法弄清楚它是什么。
最佳答案
关于linux - 防止 case 语句不断要求输入,以便我可以执行后续命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37573043/