Hello all,
Below is scripts to find the file following by:
30 days <- How many total file space within 30 days and not quantity
90 days
120 days
1 year
From here also I can get data space to put on PIE Chart. Following this scripts can I do some enhance from this scripts like do single command then can get total data follow 30 days, 90 days, 120 days and 1 year.
What I'm trying to to is:
- Get file like "ls -lR | egrep ^-" > test.txt
- From test.txt get all category 30day, 60day, 90day and 1 year.
- Value of date convert to percentage.
- Save as *.csv
Sample for .CSV:
30 days, 20
60 days,30
90 days,40
365 days,80
Scripts A - Get data by day
#!/bin/sh
find /mnt/emage -type f -mtime -30 ! -mtime -0 -exec ls -la {} \; > 30days.txt
cat 30days.txt | awk '{ SUM += $5} END { print "30days " SUM }' >> agging.txt
find /mnt/emage -type f -mtime -90 ! -mtime -60 -exec ls -la {} \; > 90days.txt
cat 90days.txt | awk '{ SUM += $5} END { print "90days " SUM }' >> agging.txt
find /mnt/emage -type f -mtime -180 ! -mtime -150 -exec ls -la {} \; > 120days.txt
cat 120days.txt | awk '{ SUM += $5} END { print "120days " SUM }' >> agging.txt
find /mnt/emage -type f -mtime -365 ! -mtime -335 -exec ls -la {} \; > 365days.txt
cat 365days.txt | awk '{ SUM += $5} END { print "365days " SUM }' >> agging.txt
cat agging.txt | awk '{ $2=$2/1073741824 ; print $1 "," $2 }' > agging.csv
mv agging.csv age.csv
rm agging.txt
Scripts B - Profiler
#!/bin/sh
ls -lR | egrep ^- > test.txt
Type[1]='"\.avi\$|\.mov\$|\.mp3\$"'
LABEL[1]=Media
Type[2]='"\.doc\$|\.xls\$"'
LABEL[2]=Document
Type[3]='"\.png\$"'
LABEL[3]=Image
for count in 1 2 3;
do
echo ${LABEL[$count]},`eval egrep ${Type[$count]} test.txt |awk '{ SUM += $5} END { SUM=SUM/1073741824 ; print SUM" GB"}'`
done
# Available space
df -P /mnt/emage | awk 'NR==2{print "Available,"$4/1048576" GB"}'
It is posible scripts A follow as scripts B?