the -e switch used with echo enables it to understand escape sequences as so:
[root@localhost~]# echo -e 'hello\b\bhi'
helhi
[root@localhost~]#
But, the escape sequences are seemingly skipped in the snippet below:
[root@localhost~]# echo -e 'hello\b\b'
hello
[root@localhost~]#
Can anyone help understand the behavior of the above code snippet?
When the same code snippet above, is executed in conjugation with the '-n' switch, it works! (ofcourse, with the -n behaviour where it removes the linefeed)
[root@localhost~]# echo -n -e 'hello\b\b'
hel[root@localhost~]#
Regards
\b
escape causes a backspace+delete rather than just a backspace (reposition cursor) ? – user4556274 Jun 13 '20 at 11:43UNIX
certified platform,-e
is printed as the firstecho
argument. – schily Jun 13 '20 at 11:58UNIX
certified platforms, evenbash
is compiled in a way that makedit behave conformant. CheckMacOS
orSolaris
... – schily Jun 13 '20 at 12:04-e
see https://unix.stackexchange.com/q/65803/5132 and https://unix.stackexchange.com/q/55101/5132 . – JdeBP Jun 13 '20 at 15:57