-
Notifications
You must be signed in to change notification settings - Fork 0
/
chksize
executable file
·53 lines (45 loc) · 1.01 KB
/
chksize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# for search
# tag : recursion du check size
DEPTH=$1
CURRENT=0
# SPACE=" " * ${CURRNET}
echo "DEPTH : ${DEPTH}"
echo "---"
# Recursion
FirstClass() {
# echo "$1"
cd "$1"
echo "|"
echo "|"
# list to array
# FILENAMES=("`ls -l | grep -v 'total' | grep -v '\.' | grep -v '\.\.' |awk '{print $NF}'`")
FILENAMES="`ls -l | grep -v 'total' | grep -v '\.' | grep -v '\.\.' |awk '{print $NF}'`"
SPACE=" "
echo $SPACE
for FILENAME in ${FILENAMES}
do
# echo "file : ${FILENAME}"
SIZE=`du -sh ${FILENAME} | awk '{print $1}'`
# seem to be tree
if [ -f ${FILENAME} ]
then
echo "${SPACE} - ${FILENAME} ${SIZE}"
echo "|"
elif [ -d ${FILENAME} ]
then
if [ ${CURRENT} -le ${DEPTH} ]
then
echo "${SPACE} --- ${FILENAME} ${SIZE}"
CURRENT=$((CURRENT+1))
FirstClass "${FILENAME}"
# echo "DEPTH : ${CURRENT}"
fi
fi
done
CURRENT=$((CURRENT-1))
# echo "DEPTH : ${CURRENT}"
cd ../
}
# call function
FirstClass