我.html在Bash中解析一些文件.我读了输入:
while read line
do
echo $line
...do something...
done < $file
Run Code Online (Sandbox Code Playgroud)
现在我已经看到了一些非常奇怪的东西.文件中的某些行包含类似的内容
Resolution…: 720 * 576
Run Code Online (Sandbox Code Playgroud)
但是bash给了我这个:
Resolution…: 720 mysript.sh another_script.pl 576
Run Code Online (Sandbox Code Playgroud)
Bash将扩展* char到实际目录的内容.如何在不扩展的情况下逐行阅读文本.
你应该使用-r选项读取你的文件
while read -r line
do
echo "$line"
#..do something...
done < "$file"
Run Code Online (Sandbox Code Playgroud)