sh read command eats backslashes in input?
Use read -r
, as per http://www.ss64.com/bash/read.html:
-r
If this option is given, backslash does not act as an escape character.
Accrding to: http://www.vias.org/linux-knowhow/bbg_sect_08_02_01.html :
-r
If this option is given, backslash does not act as an escape character. The backslash is considered to be part of the line. In particular, a backslash-newline pair may not be used as a line continuation.
It works on my machine.
$ echo '\&|' | while read -r in; do echo "$in"; done
\&|