Refactoring based on examples from another pbulk script

http://mail-index.netbsd.org/pkgsrc-users/2013/11/09/msg018881.html
Rearrange the script for clarify

...now that I understand a few more shell tricks