#!/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