sh
is notbash
. This shouldn't be a problem for your script though, because I don't think there are any bashisms in there.Use More Quotes™. If there had been another parameter in the URL you would have needed an ampersand (
&
) in there, and that's the special character to run a command in the background. That's one of many ways to trip up if you don't comment basically any non-trivial string.You don't need to
sleep
, because thewget
commands are synchronous.That said, you might get a result much faster if you run them in parallel, by doing several
wget […] &
commands followed by await
.You don't need to
exit
at the end of a shell script. That's only useful if you want to exit prematurely or with a different exit code from the previous command.If you use Bash you can use
read -p "Start file #: " start
etc. to avoid most of theecho
ing.However, it is much more common to make shell scripts take parameters instead of being interactive, making the script even simpler:
start="$1" end="$2"
Use
set -o errexit -o nounset
(and-o pipefail
if you're really in Bash) to make sure you catch any common bugs early.I'm not sure what
progressfilt
does, but you can suppress thewget
progress bar by using--quiet
.To be done slightly faster you should swap around the deleting and the renaming.
Rather than
find *
you should usefind .
to avoid exceeding the maximum argument length. This is a good practice in general, but will only really break with lots of files.One very common feature of *nix scripts is that they are silent unless there's something important to report. Therefore, I'd remove the last
echo
.
Your script should now be 9 SLOC, and clean as a whistle!