[an error occurred while processing this directive].com

5Oct/071

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)

Filed under: code Leave a comment
Comments (1) Trackbacks (0)
  1. pipe is your friend!

    wget -O – | tar zxf -


Leave a comment


No trackbacks yet.