我有一个具有以下内容的文本文件,
My test
strings
that dont have
a question
mark except this line?
but not
these two
并且当我尝试使用例如bash读取bash文件时>
ph_lines="/path/to/file.txt" for l in $(cat "$ph_lines") do echo "$l" done
除了输出中所有带有问号的字符串,所有内容都会打印在输出上。
我曾尝试使用while read line; echo line; done < $filename
,但仍然存在相同的问题
唯一可以捕获所有行的方法是当我使用sed删除问号时。
for l in $(cat ${ph_lines} | sed $'s/\?//' )
谢谢!
我有一个包含以下内容的文本文件,我的测试字符串除此行外没有问号?但不是这两个,当我尝试使用例如...
要正确读取文件,请使用Read a file line by line assigning the value to a variable中的示例: