armandfp
armandfp

Reputation: 1069

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?

Upvotes: 2

Views: 296

Answers (1)

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143051

Then try read -r line instead.

Upvotes: 4

Related Questions