Subversion Progressbar in bash

For a project i am doing i needed to checkout a subversion repo from within an installer. This ofcourse is not that hard, but i wanted something extra.
I was searching for a way to show a progressbar when doing a svn checkout (svn co) and could not find a sollution for it. So i came up with the following sollution.

First, i needed to know how many files i was going to checkout of the subversion repository. To get this number i’m going to use the following bash statement.

Great, ‘$n’ now contains a number of files in my project, we can use that number to calculate the percentage. But to do that i needed to know how far the checkout is.

Subversion will output each file on a new line. We could pipe that into a while loop and keep track of the progress.

The script above prints a percentage for each line.

Now let’s put all this into a dialog.

if you run this you’ll get a nice process indicator. Yay!