#!/bin/bash DEB=$1 DIR=$(echo $DEB | sed 's/\.deb//') #Solves for already existing DIR NUM=0 while [ -d $DIR ] ; do let NUM=$NUM+1 DIR=$DIR"_$NUM" done #Attach the / to the DIR DIR=$DIR"/" #Extract data files and then control files dpkg -x $DEB $DIR && dpkg -e $DEB $DIR"DEBIAN"