#!/usr/bin/sh
FILE_NAME=./test.txt
while read LINE < $FILE_NAME
do
echo "$LINE"
:
done
写了一个最简单的shell脚本,目的是把一个文件逐行读出来,
但是现在读出来的结果是只能读第一行,请高手指点一下,谢谢。
读取的文件内容
line1
line2
line3
line4
好像没什么分了,可能没法结贴了,请大侠见谅
------解决方案--------------------------------------------------------
应该反过来写。
#!/usr/bin/sh
FILE_NAME=./test.txt
while read LINE
do
echo $LINE
:
done < $FILE_NAME
------解决方案--------------------------------------------------------
man read
EXAMPLES
Print a file with the first field of each line moved to the end of the
line.
while read -r xx yy
do
printf "%s %s \n" "$yy" "$xx"
done < input_file