简体   繁体   中英

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 ...

and i use a bash script to read this file like

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

and returns all good, but in the message 3, just return:

  1. you don't have rights to do this

without the "\\"

how i can return the exactly line?

然后尝试read -r line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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