1

My bash script contains the clear command, that when executed through dialog command will result with strange letters. How can I still use clear command without seeing this output in the dialog?

This is an example of how to produce this:

#!/bin/bash
echo "starting..."
clear
echo ""
echo "End"

I'm using the dialog sort of like this:

bash /tmp/1.sh | dialog --progressbox 30 80

enter image description here

1 Answer 1

4

You could redirect the output of clear to the terminal:

#!/bin/bash
echo "starting..."
clear >$(tty)
echo ""
echo "End"

clear writes to its standard output, which (when redirected in this manner) can be different from the script's standard output.

2
  • its almost works for me because from some reason if you have 'sleep' command also between echo's command the dialog completely distorted. just add 'sleep 1' between echo command and see in order to simulate it. Commented Dec 6, 2015 at 12:28
  • sleep is a different problem: writing through a pipe, the data is not line-buffered, and the sleep acts to make that apparent. Commented Dec 6, 2015 at 23:25

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.