I want to do something like this:
#!/bin/bash
for var in a b c d e f; do
read -n1 $var
[[ "${!var}" == "d" ]] && continue the_previous_item
echo ${!var}
done
But:
continue
only accepts integers.continue
(AFAIK) doesn't have a previows item option.Is there any proper solution/workaround/hack to do this?
答案 0 :(得分:1)
你不太清楚你期望的行为。这会解决您的问题吗?
for var in a b c d e f; do
while [ 1 ]; do
read -n1 $var
[[ "${!var}" == "d" ]] && continue
break
done
echo ${!var}
done