0

To automate access to my scanner, I'm trying to cat the output of scanimage -L into a Bash variable. In fact I was successfully doing this until recently with siL="$(scanimage -L | grep net | awk '{ print $2 }' )" in my Scan.sh, getting me addresses like hpaio:/net/ENVY_5530_series?ip=192.168.43.249 stored in $siL. I've today noticed an odd glitch which I've reduced to a minimum example here following.

Given a file lines containing just this text:

LINE1
LINE2_this_string_containing_an_embedded_question_mark_-> here?itis <-_doesn't_appear_if_cat_is_invoked_via_command_substitution
LINE3

cat lines correctly shows the file, but

$ L="$(cat lines)"; echo $L
LINE1 LINE2_this_string_containing_an_embedded_question_mark_-> <-_doesn't_appear_if_cat_is_invoked_via_command_substitution LINE3

(and the same if I replace cat with <). Why is that word containing the question mark omitted?

joharr
  • 144

0 Answers0