dirsize=`df -k $src | tail -1 | awk '{print substr($4, 1, length($4) -1);}'`
Tuesday, September 15, 2009
Removing n Oldest files in a Unix/Linux mount point
To remove the oldest files even though they lie in multiple directories
files=`find /var/share/temp/ \( ! -regex '.*/\..*' \) -type f -exec stat -c "%y %n" {} \; | sort | head -5 | tr -s ' ' ' ' | cut -d' ' -f4 "$@" `
for file in $files
do
rm -f ${file}
done
files=`find /var/share/temp/ \( ! -regex '.*/\..*' \) -type f -exec stat -c "%y %n" {} \; | sort | head -5 | tr -s ' ' ' ' | cut -d' ' -f4 "$@" `
for file in $files
do
rm -f ${file}
done
Subscribe to:
Posts (Atom)
.jpg)