A Unix shell script to clean all SBT subdirectories

In a recent attempt at freeing up some disk space, I wrote this little Unix shell script to go through all of my Scala/SBT project directories, and run the sbt clean command in each directory:

#!/bin/sh

# WARNING: make sure you have backed up your files
# and directories before running this script.
for file in `cat sbt_dirs`
do
    dir=`dirname $file`
    echo "WORKING ON $dir"
    cd $dir
    sbt clean
    cd -
done

This script assumes that you have a list of the desired subdirectories in a file named sbt_dirs.

Sadly, I forgot to check the before and after disk space comparison, so I can only guess that it helped by deleting all the SBT project and target subdirectories it generates.