#!/bin/ksh # This shell script will determine what files in an RCS tree have been changed # since 00:00 on a given date. The default is to give the files that have # changed since the start of the current day, but given an offset using the # '-o' option, will find the files changed since 00:00 on that date. The '-f' # option can also be used to specify the RCS tree to be checked. # This shell script determines from date(1) what today's date is, then will # output the date in the format yymmdd. If an offset is specified using the # "-o" option, it will determine the date of the day corresponding to the # current date + or - the offset (using the sign supplied by the user). # An example follows: # # rcsnew -o 4 # # will show files created or modified date four days in the future. :-) # # rcsnew -o -27 # # will list files created or modified in the last 27 days. # # The algorithm will work across months and years, and will determine # leap years. # # $Header: /home/hugh/sources/misc/rcsnew,v 1.3 2005/02/22 15:23:33 hugh Exp hugh $ # # Author: Hugh Mahon |__| # | | # |\ /| # e-mail: hugh@mahon.cwx.net | \/ | # #set -x function year_len { let leap=0 let daysInYear=365 if (( $year % 400 == 0 )) then let daysInYear=366 let leap=1 elif (( $year % 4 == 0 )) && (( $year % 100 != 0)) then let daysInYear=366 let leap=1 fi } # # Execute rlog with parameter to check for a revision that has # been created since $newer_than. Pipe the output through grep # and sed to get the latest revision number. # rcs_newer() { newer_revision="`/usr/bin/rlog -d${DATE2}'<' ${file_name} | grep '^revision[^s]' | sed -e 's/revision //'`" if [ -n "$newer_revision" ] then echo $file_name fi } root_dir="." usage() { echo "usage: $0 [-o #] [-f root_dir]" >&2 echo " where -o # specifies an offset from today's date (+/-)" >&2 echo " -f # specifies the root directory of the RCS tree" >&2 echo " -F display only files (not directories)" >&2 echo " -s produce names of files only" >&2 exit } if [ $# -eq 0 ] then usage fi silent="" find_arg="" while [ $# -gt 0 ] do case $1 in -o) offset=$2 shift;; -f) shift root_dir=$1;; -F) find_arg="-type f";; -s) silent="y";; *) usage;; esac shift done today_date=`date +%j` let today_date=today_date+$offset year=`date +%Y` leap=0 let daysInYear=365 year_len if (( today_date < 1 )) then while (( today_date < 1 )) do let year=year-1 year_len let today_date=today_date+daysInYear done fi if (( today_date > daysInYear )) then while (( today_date > daysInYear )) do let today_date=today_date-daysInYear let year=year+1 year_len done fi let i=1 let days=0 let this_month=0 let days_so_far=0 while [ $i -le 12 -a $this_month -eq 0 ] do if [ $i = 1 -o $i = 3 -o $i = 5 -o $i = 7 -o $i = 8 -o $i = 10 -o $i = 12 ] then let days=days+31 elif [ $i = 4 -o $i = 6 -o $i = 9 -o $i = 11 ] then let days=days+30 elif [ $i = 2 -a $leap -eq 1 ] then let days=days+29 elif [ $i = 2 ] then let days=days+28 fi if (( days < today_date )) then let days_so_far=days else let this_month=i fi let i=i+1 done let day=today_date-days_so_far let year=year%100 if (( this_month < 10 )) then DATE="0$this_month" else DATE="$this_month" fi if (( day < 10 )) then DATE="${DATE}0$day" else DATE="$DATE$day" fi DATE="${DATE}0000$year" if [ -z "$silent" ] then echo "Files changed since $this_month/$day/$year" echo " " fi touch /tmp/file$$ DATE2="$year/$this_month/$day" if [ -z "$silent" ] then #echo touch -am $DATE /tmp/file$$ echo touch --date="$this_month/$day/$year" /tmp/file$$ fi touch /tmp/file$$ #touch -amc $DATE /tmp/file$$ touch --date="$this_month/$day/$year" /tmp/file$$ #find $root_dir -name '*,v' -newer /tmp/file$$ -print find $root_dir $find_arg -follow -newer /tmp/file$$ -print | while read file_name do if [ -n "`echo $file_name | grep ',v'`" ] then rcs_newer else echo $file_name fi done rm /tmp/file$$