add old ebuilds from svn ub0rlay
[ub0rlay.git] / app-portage / distclean / files / distclean-2
blob201f07016daf8e6882ac92ef3cd11d9272f0ebf9
1 #! /bin/bash
3 DISTDIR=/usr/portage/distfiles
5 echo -n "current size: "
6 du -sh "${DISTDIR}" | cut -f1
8 FILELIST=$(ls -1 "${DISTDIR}" | sed -e 's/-[0-9].*//' -e 's/_[0-9].*//' | sort -u)
10 for file in $FILELIST ; do
11 num=$(ls -1d ${DISTDIR}/${file}* 2> /dev/null | wc -l)
12 if [ $num -gt 1 ] ; then
13 num=$(($num - 1))
14 ls -1d ${DISTDIR}/${file}* | head -n ${num} | xargs -n1 rm
15 fi
16 #echo keep $(ls -1d ${DISTDIR}/${file}* | tail -n1)
17 done
20 echo -n "current size: "
21 du -sh "${DISTDIR}" | cut -f1