Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Nov 2006 12:40:56 -0600 (CST)
From:      "J. R. Lenz" <ralf@starshadow.com>
To:        freebsd-ports@freebsd.org
Subject:   useful shell script
Message-ID:  <Pine.LNX.4.62.0611041231220.397@fangorn.starshadow.com>

next in thread | raw e-mail | index | archive | help
Reclaiming disk space was a high priority on my laptop, which has a 4gb 
FreeBSD partition.  So, I wrote a useful shell script for removing all the 
"work" directories in the ports tree (I'm sure someone has already done 
this, but it saves a little bit of time for those people who are not 
fluent in shell scripting).  You'd be surprised how much disk space can be 
freed up by removing unused source code and compiled objects.

Peace,
- Ralf

#!/bin/sh
#
# remove_work.sh
# removes nasty, disk-hogging source code
#   and compiled objects from ports tree
#
# J. Ralf Lenz <ralf@starshadow.com>
#

for i in `ls -Ad *`
do
   if [ -d /usr/ports/$i ]; then
     cd $i
     DIR=`pwd`
     DESIRED_PATH=/usr/ports/$i
     if [ "${DIR}" = "${DESIRED_PATH}" ]; then
       for j in `ls -Ad *`
       do
         if [ -d /usr/ports/$i/$j ]; then
           cd /usr/ports/$i/$j
           if [ -d /usr/ports/$i/$j/work ]; then
             CUR_DIR=`pwd`
             echo "Removing ${CUR_DIR}/work..."
             rm -rf work
           fi
           cd /usr/ports/$i
         fi
       done
       cd /usr/ports
     fi
   fi
done


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
J. Ralf Lenz                            ralf@starshadow.com

    "Only two things are infinite, the universe and human
     stupidity, and I'm not sure about the former."
                     -- Albert Einstein
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.62.0611041231220.397>