Useful script for downloading on linux

I always go through the same three steps to download a file (in tar.gz format)

  1. wget the tar.gz file I want
  2. untar it
  3. remove the original file I downloaded

So I made a bash script that does those three steps in one. Use it the same way as wget (# simple.sh http://path/to/file.tar.gz)


#!/bin/bash 

# change this to whatever extension you'd like to handle
ext=".tar.gz"

# flags to pass to tar
flg="-zxvf"

wget $1

file=`ls -t *$ext | grep -i -m 1 "^.*$ext$"`

if [[ -n $file ]]
then
    tar $flg $file
    unlink $file
else
    echo "Could not find the downloaded file."
fi


You can download it via this link (Remember to make it executable and to change its extension)

One thought on “Useful script for downloading on linux

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>