#!/bin/bash
# Script to output the total size of requested filetype recursively
# Error out if no file types were provided
if [ $# -lt 1 ]
then
echo "Syntax Error, Please provide at least one type, ex: sizeofTypes {filetype1} {filetype2}"
exit 0
fi
#set first filetype
types="-name *."$1
#loop through additional filetypes and append
num=1
while [ $num -lt $# ]
do
(( num++ ))
types=$types' -o -name *.'$$num
done
echo "TYPES="$types
find . -name '*.'$1 | xargs du -ch *.$1 | grep total
The problem I'm having is right here:
#loop through additional filetypes and append
num=1
while [ $num -lt $# ]
do
(( num++ ))
types=$types' -o -name *.'>>$$num<<
done
I simply want to iterate over all the arguments not including the first one, should be easy enough, but I'm having a difficult time figuring out how to make this work