逐行迴圈遍歷檔案
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