I am building a script to identify those files created/modified today and with file size 0. I am able to find the files with 0 file size and created/modified in last 24 hrs as shown below but not today (current date), I tried using (touch -t time filenm) but in my version of unix at work it does not allow me to, please post if somebody has an alternative solution,
Here is my current script,
cd /usr/local/upload;
for i in *;do
if [ -f $i ];then
if [ ! -s $i ];then
find $i -type f -mtime -1;
fi
fi
done >> usr/file3.txt
> cat today_empty.sh
#! /usr/bin/bash
# script to show empty files created on this day
# original posting to www.unix.com
ls >today_empty_mylist
month=$(ls -l today_empty_mylist | awk '{print $6}')
day=$(ls -l today_empty_mylist | awk '{print $7}')
#echo $month $day
while read myfile
do
if [ -s $myfile ]
then
continue
fi
# ls -l $myfile
ls -l $myfile | awk -v mon=$month -v day=$day '$6==mon && $7==day {print $9}'
done<today_empty_mylist
I think this is the issue
The old version of touch does not allow the creation of a filetime on a comparison file,
for example the OP wants to be able to create a file with a filetime like this:
-rw-rw-rw- 1 jmcnama prog 0 Nov 21 00:00 a.lis
Where Nov 21 00:00 has to be dynamic, and is today's first second.
ctime is just the time the inode was changed - nothing else. It is not a create date - they do not exist in standard UNIX.
If the OP has perl v 5.8 you can write perl code to do this. I posted ancient POSIX.1 C code that does that and some other stuff - poorly. If we knew the OS and version it might help. If the OP could compile gnu version of touch that would be good.