# Progress indicator script

**URL:** <https://community.unix.com/t/progress-indicator-script/214868>\
**Category:** Shell Programming and Scripting\
**Created:** [October 2, 2008, 10:35am UTC](https://community.unix.com/t/progress-indicator-script/214868 "2008-10-02T10:35:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_hari.sh](https://community.unix.com/user_avatar/community.unix.com/_hari.sh/32/607_2.png) [@\_hari.sh](https://community.unix.com/u/_hari.sh)\
**Post date:** [October 2, 2008, 10:35am UTC](https://community.unix.com/t/progress-indicator-script/214868/1 "2008-10-02T10:35:36Z")

</div>

Can anybody suggest you a good script to show progress of a process.

I figured it out some thing like this. But cursor goes to the end of the line and after every loop it goes to the next line.

```nohighlight
while true ; do
for i in \| \/ \- \\ \| \/ \- \\
do
echo "\b\b$i \c"
sleep 1
done
done

```

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/5_5575768a8748004e209b776fc1b2916d.png) [@era](https://community.unix.com/u/era)\
**Post date:** [October 2, 2008, 2:13pm UTC](https://community.unix.com/t/progress-indicator-script/214868/2 "2008-10-02T14:13:32Z")

</div>

The carriage return character (\r, ASCII 13) returns the cursor to beginning of line without advancing to the next line.

If you have printf that might be slightly less unwieldy than echo.

---

<div class="post-metadata">

**Author:** ![Franklin52](https://community.unix.com/user_avatar/community.unix.com/franklin52/32/500_2.png) [@Franklin52](https://community.unix.com/u/Franklin52)\
**Post date:** [October 2, 2008, 3:34pm UTC](https://community.unix.com/t/progress-indicator-script/214868/3 "2008-10-02T15:34:42Z")

</div>

Try echo -n.

Regards

---

<div class="post-metadata">

**Author:** ![nua7](https://community.unix.com/letter_avatar/nua7/32/5_5575768a8748004e209b776fc1b2916d.png) [@nua7](https://community.unix.com/u/nua7)\
**Post date:** [October 3, 2008, 2:14am UTC](https://community.unix.com/t/progress-indicator-script/214868/4 "2008-10-03T02:14:30Z")

</div>

One more way of doing this..

```nohighlight
#!/bin/sh

percent=0
(
while test $percent != 101
do
echo $percent
echo "XXX"
echo "This is how the gauge appears"
echo "XXX"
echo "See how the message changes"
echo "XXX"
percent=`expr $percent + 1`
sleep 1
done
) |
dialog --title "Main Window!" --gauge "This is how a gauge appears on the command line" 10 60 0

```

---

<div class="post-metadata">

**Author:** ![\_hari.sh](https://community.unix.com/user_avatar/community.unix.com/_hari.sh/32/607_2.png) [@\_hari.sh](https://community.unix.com/u/_hari.sh)\
**Post date:** [October 3, 2008, 3:52am UTC](https://community.unix.com/t/progress-indicator-script/214868/5 "2008-10-03T03:52:07Z")

</div>

It seems This is for Linux. My machine is UX

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/5_5575768a8748004e209b776fc1b2916d.png) [@era](https://community.unix.com/u/era)\
**Post date:** [October 3, 2008, 4:04am UTC](https://community.unix.com/t/progress-indicator-script/214868/6 "2008-10-03T04:04:11Z")

</div>

You can get dialog for HP-UX too. [http://hpux.connect.org.uk/hppd/hpux/Shells/dialog-1.1/](http://hpux.connect.org.uk/hppd/hpux/Shells/dialog-1.1/)

(Funny they should use Debian as their upstream, though. According to the corresponding Debian packages, the original upstream is ftp://invisible-island.net/dialog/. I found a home page at [http://invisible-island.net/dialog/dialog.html.\](http://invisible-island.net/dialog/dialog.html.%5C))

---

<div class="post-metadata">

**Author:** ![\_hari.sh](https://community.unix.com/user_avatar/community.unix.com/_hari.sh/32/607_2.png) [@\_hari.sh](https://community.unix.com/u/_hari.sh)\
**Post date:** [October 3, 2008, 5:15am UTC](https://community.unix.com/t/progress-indicator-script/214868/7 "2008-10-03T05:15:47Z")

</div>

Thank you era!! let me try

---

<div class="post-metadata">

**Author:** ![\_hari.sh](https://community.unix.com/user_avatar/community.unix.com/_hari.sh/32/607_2.png) [@\_hari.sh](https://community.unix.com/u/_hari.sh)\
**Post date:** [October 3, 2008, 12:58pm UTC](https://community.unix.com/t/progress-indicator-script/214868/8 "2008-10-03T12:58:22Z")

</div>

Thank you nua7 and era. I could recall my favourite dialog boxes in my UX Box now...

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [October 3, 2008, 5:37pm UTC](https://community.unix.com/t/progress-indicator-script/214868/9 "2008-10-03T17:37:10Z")

</div>

The alarm disciple function of ksh93 can be used to output a progress bar as the following simple example shows:

```nohighlight
#!/usr/bin/ksh93

alarm -r progressbar +1

progressbar.alarm()
{
   tput cup 2 10
   (( ++progressbar.pvalue > 50 )) && {
      tput cup 2 10; tput el
      progressbar.pvalue=0
   }
   printf "Progress: %s" "${progressbar.pstr:1:${progressbar.pvalue}}"
}

progressbar.pvalue=0
progressbar.pstr="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

tput clear
read dummy # dummy wait - press return to exit
tput clear

exit 0

```
