逐行循环遍历文件
while IFS= read -r line; do
echo "$line"
done <file
如果文件最后可能不包含换行符,则:
while IFS= read -r line || [ -n "$line" ]; do
echo "$line"
done <file
while IFS= read -r line; do
echo "$line"
done <file
如果文件最后可能不包含换行符,则:
while IFS= read -r line || [ -n "$line" ]; do
echo "$line"
done <file