为什么在bash / ksh中的readline调用仅读取第一行

时间:2019-01-11 17:58:00

标签: linux bash ksh

我有这段代码:

file="/dir/conf/file.config"
# while loop
while IFS='|' read -r source target filecount
do
     echo "source: ${source}"
     echo "target: ${target}"
     echo "filecount: ${filecount}"
     echo "======================="
done < "$file"

此代码的工作是读取此配置文件:

Source1|Target1|1
Source2|Target2|2
Source3|Target3|4
Source4|Target4|3
Source5|Target5|6

读取在Source4处停止,并跳过最后一行。 如何确保它读取所有行? 谢谢!

0 个答案:

没有答案