0

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?

Kerby82
  • 4,934
  • 14
  • 48
  • 74
  • This might help: `{ echo "ciao" && print "\033[1A\033[K"; } > /tmp/output` – Cyrus Feb 17 '21 at 19:53
  • What's the difference? – Kerby82 Feb 17 '21 at 19:56
  • It's correct syntax. I assume that you do not have a command on your system called `{echo`. – Cyrus Feb 17 '21 at 20:02
  • When the commands are grouped with `{` and `}`, these characters must be separated by whitespaces. Also, the command(s) inside must be ended by a `;`. – M. Nejat Aydin Feb 17 '21 at 20:04
  • Oh that's a wrong copy and paste, going to edit the question. But question was not about the syntax. – Kerby82 Feb 17 '21 at 20:08
  • Do you mean `printf`, instead of `print`? – M. Nejat Aydin Feb 17 '21 at 20:14
  • I mean that I want an output without the non printable chars but that is empty and not revealing the word. At this point I'm able to remove the non printable chars but that will reveal the word ciao. Something like get the output without the non print chars keeping the behaviour of the output with the non print chars. – Kerby82 Feb 17 '21 at 20:20
  • The comment however *was* about wrong and crippling syntax, and you should be graciously accepting any such corrections, and not be haughty about it. –  Feb 17 '21 at 23:20
  • I did not want to be rude at all. Sorry for the misunderstanding and thanks for helping – Kerby82 Feb 17 '21 at 23:54

0 Answers0