linux - bash 中的转义变量

标签 linux bash

我有一个文本文件,其中有很多行,例如消息:

  1. valid user
  2. operation enable
  3. you don\'t have rights to do this
  4. please enter more than 5 characters ...

我使用 bash 脚本来读取这个文件,例如

while read line
do
    ....
    echo "${line}"
    ....
done

并且返回一切都很好,但是在消息3中,只需返回:

  1. you don't have rights to do this

没有“\”

如何返回准确的行?

最佳答案

然后尝试改为read -r line

关于linux - bash 中的转义变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8506592/

相关文章:

c++ - 编译的共享库依赖于特定的 libicuuc.so.46 版本

python - 为什么使用 sudo 运行脚本或使用 crontab 计划会导致错误?

python - bash 脚本中的 pip -r 错误

bash - 使用 wget 到 "checkout"svn 存储库

linux - Vmrun超时命令

c - 如何知道何时需要刷新缓冲区?

linux - 添加引号的字段分隔

mysql - MySql SSl 连接问题

linux 无法将文件复制到服务器访问被拒绝

bash - zsh 中的 IFS 行为与 bash 不同