Let's say I have this command:
{ echo "ciao" && print "\033[1A\033[K"; } > /tmp/output
If I open /tmp/output I will see an empty file even though the real file contains ciao and then some unprintable chars that delete line.
I would like to remove the unprintable chars from the file without revealing the word ciao.
If I do:
cat /tmp/output | LC_ALL=C tr -c '[[:print:]]' ' '
ciao [1A [K %
This is because once unprintable chars are removed the word ciao is revealed, is there a way to eliminate the special chars keeping the expected behavior as output?