0

i read a line from another file that contains a backslash, and i want to echo this line without expanding the backslash :

script.sh :

#!/bin/bash

while read line do echo "$line" done < script_sample.txt

script_sample.txt :

echo \"

execution :

PROMPT> bash script.sh
echo "
PROMPT>

instead i would like :

PROMPT> bash script.sh
echo \"
PROMPT>

and i can't touch the lines inside script_sample.txt, otherwise i would use single quotes ' or another backslash \

i really don't know how to do that ? i supposed it could be something like echo $'line' or ${'line'} that would expand the variable $line but not its content, but i can't figure it out

maybe there is something to do with variable substitution ?

hugogogo
  • 121

0 Answers0