我发现下面一段代码被写为shell脚本以逐行读取文件。从文件中读取时执行exec命令的重要性
BAKIFS=$IFS
IFS=$(echo -en "\n\b")
exec 3<&0
exec 0<"$FILE"
while read -r line
do
# use $line variable to process line in processLine() function
processLine $line
done
exec 0<&3
# restore $IFS which was used to determine what the field separators are
IFS=$BAKIFS
我无法理解需要提到的三个exec命令。有人能为我详细说明吗?在每次从文件读取之后,$ ifs变量是否重置?
非常感谢pax ....假设我在后台服务器上运行此脚本。然后在while循环的持续时间期间标准输入将设置为3.这是否意味着我不能使用标准输入在这段时间内阅读任何其他程序?任何想法,以消除这种依赖? – ayush 2011-01-11 06:28:42