我需要使用“Do / While”循环读取
一个文件.
我如何以字符串的形式读取
内容?
这是我的代码:
cat directory/scripts/tv2dbarray.txt | while read line
do
echo "a line: $line"
done
错误:
test.sh: line 4: Syntax error near unexpected token `done'
test.sh: line 4: `done'
cat file | while read line
do
echo "a line: $line"
done
编辑:
获取文件内容到var使用:
foo="`cat file`"