I want to pipe some output to another program and display a progress bar.
The code would look something like this:
echo "Progress:"
(for i in {1..10}; do echo $i; echo "." > screen; sleep 1; done) | xargs echo
where screen
would direct it to the screen. This is not working because it will just write the dots to the file screen.
What I want to do is outputting the "." while the script is running and piping all the echo "$i"
at once at the end, so only one piping occurs.
You have to send the echo to the tty device. For example, echo 'somthing' > /dev/tty
But if you only want to show dots in the screen you don't need any redirection. Only echo '.'
Try to use the /dev/stderr for writing stuff to the screen
E.g. something like this should do it.
echo "Progress:"
(for i in {1..10}; do echo $i; echo -n "." | tee /dev/stderr ; sleep 1; done)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With