I am wondering whether there exists a command in bash to print a string in a way exposes the special character it contains.
For example, suppose that a=$'\a\0\b\e'; does there exists a function to print \a\0\b\e literally from $a?
The closest I have got so far is by using the l command from sed:
echo "$a" | sed -n 'l'
which returns \a\000\b\033$, but the notation is different from that inside $'', and it doesn't work if the string contains newlines.
cat -A. It shows non-printable characters, but in the another form.echo $'\t\b\e\a' | cat -Aoutput:^I^H^[^God -c:echo $'\t\b\e\a' | od -c. Output:0000000 \t \b 033 \a \n.printf %s "$a" | hexdump -c, which gives me… \a \0 \b 033 …, i.e. just mangles the\e.\0? I don't think so. @Sparhawk, what is your bash version?