I am trying to read a line in a file which has '\' in it. But it is not showing in output, please help me what is the reason behind and how to read it.
Ex: File has this data:
abc
abc\def
but while loop took the second line as 'abcdef'
I am trying to read a line in a file which has '\' in it. But it is not showing in output, please help me what is the reason behind and how to read it.
Ex: File has this data:
abc
abc\def
but while loop took the second line as 'abcdef'
You can use the -r option. E.g in bash:
while read -r l; do
echo "$f";
done < yourfile
\ (backslash ) is an escape character . If possible use abc\\def instead of abc\def
Or use -r in your shell script as mentioned in the SO thread