请问关于shell: while read line里的line 是从哪里来的
while read line
do
# skip blank lines
if [ "${line}" = "" ]; then
continue
fi
# get action - 1st word in command
action=`echo "${line}" | cut -d" " -f1`
# Execute the command
db2 -tv "${line}"
rc=$?
if [ ${rc} -eq 0 ]; then
if [ "${action}" = "import" ]; then
if [ "${flg_del_ixf_on_import_success}" = "Y" ]; then
# get ixf filename - 3rd word in command
ixf_file=`echo "${line}" | cut -d" " -f3`
echo "rm ${ixf_file}"
rm ${ixf_file}
fi
fi
continue
fi
#=======================================
# if we get here, had non-zero ret code
#=======================================
# if command is "drop xxx", probably being done to prepare for
# a later "create xxx" command, so we'll ignore error.
if [ "${action}" = "drop" ]; then
word2=`echo "${line}" | cut -d" " -f2`
echo "Ignoring drop ${word2} error"
continue
fi
# Return immediately if rc is higher than allowed.
# Otherwise, ensure retVal is highest rc seen so far,
# so we can return highest return code when done.
if [ ${rc} -gt ${rc_max_continue} ]; then
return ${rc}
else
if [ ${rc} -gt ${retVal} ]; then
retVal=${rc}
fi
fi
done < ${filename}
程序很长,不过问题在第1行
请问第1行while语句的line 是从哪里来的呢?
整个函数都没有对Line的描述或者定义。
麻烦高手帮忙。
do
# skip blank lines
if [ "${line}" = "" ]; then
continue
fi
# get action - 1st word in command
action=`echo "${line}" | cut -d" " -f1`
# Execute the command
db2 -tv "${line}"
rc=$?
if [ ${rc} -eq 0 ]; then
if [ "${action}" = "import" ]; then
if [ "${flg_del_ixf_on_import_success}" = "Y" ]; then
# get ixf filename - 3rd word in command
ixf_file=`echo "${line}" | cut -d" " -f3`
echo "rm ${ixf_file}"
rm ${ixf_file}
fi
fi
continue
fi
#=======================================
# if we get here, had non-zero ret code
#=======================================
# if command is "drop xxx", probably being done to prepare for
# a later "create xxx" command, so we'll ignore error.
if [ "${action}" = "drop" ]; then
word2=`echo "${line}" | cut -d" " -f2`
echo "Ignoring drop ${word2} error"
continue
fi
# Return immediately if rc is higher than allowed.
# Otherwise, ensure retVal is highest rc seen so far,
# so we can return highest return code when done.
if [ ${rc} -gt ${rc_max_continue} ]; then
return ${rc}
else
if [ ${rc} -gt ${retVal} ]; then
retVal=${rc}
fi
fi
done < ${filename}
程序很长,不过问题在第1行
请问第1行while语句的line 是从哪里来的呢?
整个函数都没有对Line的描述或者定义。
麻烦高手帮忙。
...全文
相关推荐
Shell中while read用法[项目源码]
本文详细介绍了Shell脚本中while read line的两种主要用法:通过管道将command命令的输出作为read循环的输入,以及通过输入重定向直接读取文件内容。文章解释了read命令的工作原理,包括如何根据空格分隔输入并赋值给多个变量,以及read的退出状态如何影响循环执行。此外,还比较了不同读取方式的效率,指出while read line;do echo $line;done < file是效率最高的方法。通过多个示例代码展示了read在不同变量数量下的行为,包括如何处理不足的输入和空行情况。最后强调了使用输入重定向方式的内存优势和变量作用域特性。
Shell脚本从文件中逐行读取内容的几种方法实例
今天小编就为大家分享一篇关于Shell脚本从文件中逐行读取内容的几种方法实例,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
linux shell在while中用read从键盘输入的实现
下面小编就为大家带来一篇linux shell在while中用read从键盘输入的实现。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
linux shell循环:for、while、until用法详解
主要介绍了linux shell下常用的循环for、while、until的用法,这也是脚本之家小编看到的比较详细的文章了,感兴趣的朋友可以参考一下,最好是在环境下自己手工打一份,不要复制
Shell逐行读取文件的4种方法
主要介绍了Shell逐行读取文件的4种方法,本文介绍了while循环法、重定向法、管道法、文件描述符法等一些方法,需要的朋友可以参考下


