#!/bin/csh -f # # Set file's timestamp to 4 hours ago. # (Based totally on touch-24.) # # Written for MacOSX. # (Does not work on Solaris-10, where # date does not support "+%s" or "-r".) # # Brent Chivers 2010 Jun 29 # # Re-written for Linux. 2011/Jan/08 # Requires my date_name4 binary. unalias * # get other users' .cshrc stuff out of the way # set seconds = `date '+%s'` # seconds since the epoch # @ yesterday = $seconds - 14400 # seconds 4 hours earlier (4 * 60 * 60) # set date = `date -r $yesterday '+%Y%m%d%H%M.%S'` # convert seconds to touch string # touch -t $date $* # touch all files with yesterday's date/time set mmss = `/bin/date '+%M.%S'` # minutes and seconds set hh = `/bin/date '+%k'` # hour if ("$hh" > 3) then # 4 hours earlier is still today. set yyyymmdd = `/home/bchivers/bin/date_name4 = | /usr/bin/tr -d =` @ hh = $hh - 4 # 4 hours earlier if ("$hh" < 10) then set hh = "0$hh" # pad single digit with leading zero endif else # 4 hours earlier is yesterday. set yyyymmdd = `/home/bchivers/bin/date_name4 = -1 | /usr/bin/tr -d =` @ hh = $hh + 20 # 4 hours earlier endif /usr/bin/touch -t $yyyymmdd$hh$mmss $*