Skip to main content
added 155 characters in body
Source Link
l0b0
  • 9k
  • 21
  • 36
  • sh is not bash. 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 the wget 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 a wait.

  • 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 the echoing.

  • 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 the wget progress bar by using --quiet.

  • To be done slightly faster you should swap around the deleting and the renaming.

  • Rather than find * you should use find . 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!

  • sh is not bash. This shouldn't be a problem for your script though, because I don't think there are any bashisms in there.

  • Use More Quotes™.

  • You don't need to sleep, because the wget 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 a wait.

  • 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 the echoing.

  • 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 the wget progress bar by using --quiet.

  • To be done slightly faster you should swap around the deleting and the renaming.

  • Rather than find * you should use find . to avoid exceeding the maximum argument length. This is a good practice in general, but will only really break with lots of files.

  • sh is not bash. 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 the wget 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 a wait.

  • 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 the echoing.

  • 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 the wget progress bar by using --quiet.

  • To be done slightly faster you should swap around the deleting and the renaming.

  • Rather than find * you should use find . 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!

added 301 characters in body
Source Link
l0b0
  • 9k
  • 21
  • 36
  • sh is not bash. This shouldn't be a problem for your script though, because I don't think there are any bashisms in there.

    sh is not bash. This shouldn't be a problem for your script though, because I don't think there are any bashisms in there.

  • Use More Quotes™.

    Use More Quotes™.

  • You don't need to sleep, because the wget commands are synchronous.

    You don't need to sleep, because the wget 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 a wait.

    That said, you might get a result much faster if you run them in parallel, by doing several wget […] & commands followed by a wait.

  • 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.

    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 the echoing.

    If you use Bash you can use read -p "Start file #: " start etc. to avoid most of the echoing.

  • 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 the wget progress bar by using --quiet.

  • To be done slightly faster you should swap around the deleting and the renaming.

  • Rather than find * you should use find . to avoid exceeding the maximum argument length. This is a good practice in general, but will only really break with lots of files.

  • sh is not bash. This shouldn't be a problem for your script though, because I don't think there are any bashisms in there.
  • Use More Quotes™.
  • You don't need to sleep, because the wget 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 a wait.
  • 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 the echoing.
  • sh is not bash. This shouldn't be a problem for your script though, because I don't think there are any bashisms in there.

  • Use More Quotes™.

  • You don't need to sleep, because the wget 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 a wait.

  • 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 the echoing.

  • 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 the wget progress bar by using --quiet.

  • To be done slightly faster you should swap around the deleting and the renaming.

  • Rather than find * you should use find . to avoid exceeding the maximum argument length. This is a good practice in general, but will only really break with lots of files.

Source Link
l0b0
  • 9k
  • 21
  • 36

  • sh is not bash. This shouldn't be a problem for your script though, because I don't think there are any bashisms in there.
  • Use More Quotes™.
  • You don't need to sleep, because the wget 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 a wait.
  • 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 the echoing.