我有一个文本文件,其中有很多行,例如消息:
- valid user
- operation enable
- you don\'t have rights to do this
- please enter more than 5 characters ...
我使用 bash 脚本来读取这个文件,例如
while read line
do
....
echo "${line}"
....
done
并且返回一切都很好,但是在消息3中,只需返回:
- you don't have rights to do this
没有“\”
如何返回准确的行?
最佳答案
然后尝试改为read -r line
。
关于linux - bash 中的转义变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8506592/