【发布时间】:2010-04-05 23:03:33
【问题描述】:
#!/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
我遇到的问题就在这里:
#loop through additional filetypes and append
num=1
while [ $num -lt $# ]
do
(( num++ ))
types=$types' -o -name *.'>>$$num<<
done
我只是想遍历所有参数,不包括第一个参数,应该很容易,但我很难弄清楚如何完成这项工作
【问题讨论】: