简体   繁体   English

在bash中转义变量

[英]Escape variables in bash

I have a text file with a lot of lines like messages: 我有一个文本文件,其中包含很多行,例如消息:

  1. valid user 有效用户
  2. operation enable 操作启用
  3. you don\\'t have rights to do this 您无权执行此操作
  4. please enter more than 5 characters ... 请输入超过5个字符...

and i use a bash script to read this file like 我使用bash脚本读取该文件,例如

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

and returns all good, but in the message 3, just return: 并返回所有良好结果,但在消息3中,只需返回:

  1. you don't have rights to do this 您无权执行此操作

without the "\\" 没有"\\"

how i can return the exactly line? 我如何才能返回准确的线?

然后尝试read -r line

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM