1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-04 15:17:42 +02:00

More examples on dealing with cache through bash bin/cache.bash, #129.

This commit is contained in:
Mikael Roos
2015-12-02 11:04:42 +01:00
parent 8e1318c31e
commit 91ae49b3f3
2 changed files with 26 additions and 18 deletions

View File

@@ -8,6 +8,7 @@ Revision history
v0.7.7* (2015-10-25) v0.7.7* (2015-10-25)
------------------------------------- -------------------------------------
* More examples on dealing with cache through bash `bin/cache.bash`, #129.
* Added Gitter badge to README, #126. * Added Gitter badge to README, #126.
* Fix proper download url in README, #125. * Fix proper download url in README, #125.

View File

@@ -1,22 +1,17 @@
#!/bin/bash #!/bin/bash
# #
# Specify the utilities used # ls -ult list and sorts fils by its access time
# #
ECHO="printf"
# #
# Main, start by checking basic usage # Main, start by checking basic usage
# #
if [ $# -lt 1 ] if [ $# -lt 1 ]
then then
$ECHO "Usage: $0 [cache-dir]\n" echo "Usage: $0 [cache-dir]"
exit 1 exit 1
elif [ ! -d "$1" ]; then elif [ ! -d "$1" ]; then
$ECHO "Usage: $0 [cache-dir]\n" echo "Usage: $0 [cache-dir]"
$ECHO "$1 is not a directory.\n" echo "$1 is not a directory."
exit 1 exit 1
fi fi
@@ -25,12 +20,24 @@ fi
# #
# Print out details on cache-directory # Print out details on cache-directory
# #
$ECHO "Total size: $( du -sh $1 | cut -f1 )" echo "# Size"
$ECHO "\nNumber of files: $( find $1 | wc -l )" echo "Total size: $( du -sh $1 | cut -f1 )"
$ECHO "\n\nTop-5 largest files:\n" echo "Number of files: $( find $1 -type f | wc -l )"
$ECHO "$( du -s $1/* | sort -nr | head -5 )" echo "Number of dirs: $( find $1 -type d | wc -l )"
$ECHO "\n\nLast-5 created files:\n" echo
$ECHO "$( find $1/* -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r | head -5 )" echo "# Top-5 largest files/dirs:"
$ECHO "\n\nLast-5 accessed files:\n" echo "$( du -s $1/* | sort -nr | head -5 )"
$ECHO "$( find $1/* -printf '%AY-%Am-%Ad %AH:%AM %f\n' | sort -r | head -5 )" echo
$ECHO "\n" echo "# Last-5 created files:"
echo "$( find $1 -type f -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r | head -5 )"
echo
echo "# Last-5 accessed files:"
echo "$( find $1 -type f -printf '%AY-%Am-%Ad %AH:%AM %f\n' | sort -r | head -5 )"
echo
echo "# 5 Oldest files:"
echo "$( find $1 -type f -printf '%AY-%Am-%Ad %AH:%AM %f\n' | sort | head -5 )"
echo
echo "# Files not accessed within the last 30 days"
echo "Number of files: $( find $1 -type f -atime +30 | wc -l )"
echo "Total file size: $( find $1 -type f -atime +30 -exec du {} \; | cut -f1 | paste -sd+ | bc )"
echo