Summary of "Utility needed"

From: Ittai Hershman (
Date: Wed Mar 06 1991 - 14:47:52 CST

I received about 15 messages, 10 people told me how I could write one --
which I already knew. 2 people asked for copies of what I received. 1
person wrote a script (apparently in response to my message) and sent it
to me untested.

Daniel Trinkle ( of Purdue University kindly
responded with his script which he has given me permission
to repost. Dan's script also catches a condition I hadn't thought of
initially -- it doesn't try to compress files with names which end in

This, by the way, was one of the reasons I didn't want to reinivent
the wheel: invariably these things take a few passes to get right and
I prefer to take advantage of other people's learning curve experiences.

Thank you all,

     Try my script, it is exactly what you describe.

Daniel Trinkle
Dept. of Computer Sciences {backbone}!purdue!trinkle
Purdue University 317-494-7844
West Lafayette, IN 47907

# Usage: compressfs fs
# compress old files in a file system and notify users
# Daniel Trinkle
# Computer Sciences Department
# Purdue University
# May 22, 1990
export PATH
USAGE="Usage: $0 fs"
# Configuration tuning
# ADM - user to receive copy of user notices
# BIG - size of big files (in 512 byte blocks)
# OLD - old files (in days)

if [ `whoami` != "root" ] ; then
    echo "ERROR: You must be root to run $0"
    exit 1

if [ $# -ne 1 ] ; then
    echo $USAGE
    exit 1


if cd $FS ; then
    echo "ERROR: cannot change directory to $FS"
    exit 1

INODE=`ls -lid | awk '{print $1}'`
if [ $INODE -ne 2 ] ; then
    echo "ERROR: $FS is not the root of a filesystem (inode != 2)"
    exit 1

find . -type f -atime +$OLD -mtime +$OLD -size +$BIG ! -name '*.Z' -print | awk 'NF == 1 {print}' > $TMP1

USER_LIST=`awk '{split($1, p, "/"); print p[2]}' $TMP1 | sort -u`

for U in $USER_LIST ; do
    cp /dev/null $TMP2
    echo "Doing files for $U"
    grep "^\./$U/" $TMP1 | \
        while read FILE ; do
            if compress $FILE 2>/dev/null ; then
                echo $FILE >>$TMP2
    (sed -e "s;FS;$FS;g" -e "s;BIG;$BIG;g" \
         -e "s;OLD;$OLD;g" -e "s;USER;$U;g" $MESG ; \
     sed -e "s;^\./$U/;;" $TMP2) | Mail -s "Old $FS/$U files compressed" $U $ADM
    rm -f $TMP2

rm -f $TMP1 $TMP2

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:11 CDT