Question: I am currently trying to figure out how to make bash draw a series of dots across the screen (kind of like a progress indicator) until a command finishes executing. For example, say I want to draw dots for a wget download:

```
wget -s http://url.tar.gz
until "above command has finished executing"; do
    echo -n "."
    sleep 0.05s
done

```

Can I use "$!" or "$?" to help solve this?

Thank you for the help!

Answer: 
This will print dots until `wget` completes:

```
while sleep 0.1; do printf "."; done &
wget -q http://url.tar.gz
kill $!
echo "Finished"

```

`wget` has its own progress indicator. The above uses `-q` to turn that off.

`$!` expands to the PID of the last process executed in the background which, in this case, is the `while` loop that prints the dots. Thus, `kill $!` stops the loop, ending the printing of dots.
Thanks to Squirrel, I was able to solve this. He pointed me to a thread that I had duplicated [shell - get exit code of background process](https://stackoverflow.com/questions/1570262/shell-get-exit-code-of-background-process/1570356#1570356). By adding the following to my script, I was able to get it working how I had hoped:

```
wget -q http://url.example.com.tar.bz2 &
wget_pid=$!

while [ -d /proc/$wget_pid ]; do
    echo -n "."
    sleep 0.01s
done

```