#!/bin/sh
while read line
do
echo "Name: " "$line"
while []; do
#statements
done
done <input.txt
答案 0 :(得分:-2)
验证输入时使用break
。
例如:
while read -rp "Please enter email address " line ; do
if [[ "$line" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ ]]; then
echo OK
break
else
echo "Try again"
fi
done