Article Listing 1 Listing 2 Listing 3 Listing 4
Listing 5 Listing 6 Listing 7 Listing 8 Listing 9
Listing 10 Listing 11 Listing 12 dec2004.tar

Listing 7 list_added.sh

#!/bin/ksh

#**************************************************************
# Listing 7:
# File: list_added.sh
#
# Description:
#
# This script takes a file generated by the compare command and
# lists the files that were added.
#
# Author: John Spurgeon (john.p.spurgeon@intel.com)
#
#**************************************************************

if [ "$#" -ne 1 ]
then
   echo "[$(basename $0)] usage: $(basename $0) filename" >& 2
   exit 1
fi

FILE=$1

if ! [ -f $FILE ]
then
   echo "[$(basename $0)] Error: $FILE does not exist!" >& 2
   exit 1
fi

awk 'BEGIN {last = ""}
{
   if ($1 == ">") {
      if ($2 != last) {
         print $2
      }
   }
   last = $2
}' $FILE 


#!/bin/ksh