How to make 'cat' in Linux to interpret control characters How to make 'cat' in Linux to interpret control characters linux linux

How to make 'cat' in Linux to interpret control characters


Why not:

while read -r line; do echo -e $line; done < at.txt


You can simply:

echo -e $(cat at.txt)


The built-in echo command interprets the common backslash escapes. But in a file you have to interpret, or convert it in a similar way. The sed program can do this.

sed -e 's/\\r/\r/' < at.txt

But I learned somethere here, also. The external echo command behaves differently from the internal one.

/bin/echo "\r"

Has different output than

echo "\r"

But basically you need a filter to convert the litteral \r string to a single byte 0x0D.