AeroGuy5
AeroGuy5

Reputation: 13

bash: suppress kill message in while loop

I have a progress bar that prints dots as it waits for an external program to finish executing. When it does finish, I get an ugly kill message which I want to suppress.

#!/bin/bash
program < input.file.1 > output.1 &

sim='running simulation'

echo -ne $sim >&2

while kill -0 $!; do

       echo -n . >&2
       sleep 1
done

Expected: running simulation.........

Actual: running simulation........./run_with_dots.1: line 8: kill: (11872) - No such process

Upvotes: 1

Views: 223

Answers (1)

John Kugelman
John Kugelman

Reputation: 361556

Redirect stderr:

while kill -0 $! 2> /dev/null; do

Upvotes: 1

Related Questions