#!/bin/bash deb=$1 OIFS=$IFS IFS=$'\n' opt_total=0 home_total=0 other_total=0 for line in $(ar p ${deb} data.tar.gz | tar -tzvf -) ; do { IFS=$OIFS array=(${line}) case $(echo ${array[5]} | cut -b 1-5) in ./usr ) usr_total=$(( ${usr_total} + ${array[2]})) ;; ./opt ) opt_total=$(( ${opt_total} + ${array[2]})) ;; * ) other_total=$(( ${other_total} + ${array[2]})) ;; esac } ; done echo -e "Usr\tOpt\tOther" echo -e "${usr_total}\t${opt_total}\t${other_total}" IFS=$OIFS