1833883 Members
1944 Online
110063 Solutions
New Discussion

Re: scripts help

 
Sir T S S
Advisor

scripts help

hi ,
how to do a simple scripts when the scripts check for the today file based on today date, if exist and size > 0 then perform the processing.

any help is appreciated.
4 REPLIES 4
jpcast_real
Regular Advisor

Re: scripts help

with the command find . -ctime -1 you can get the files which have been modified the last 24 hours .

You can also test if a file exists or not. Example:


if [ -r /etc/rc.config.d/samba ]
then . /etc/rc.config.d/samba
fi

Also you can get the size of a file:

ll | awk '{ print $5 }'
Here rests one who was not what he wanted and didn't want what he was
Biswajit Tripathy
Honored Contributor

Re: scripts help

An addition to previous reply.
"find . -ctime 1" lists files that has their status changed
in last 24 hrs. To see file that were modified in last 24
hrs, use "-mtime" instead of ctime.

One key thing is, last 24hr is not necessarily today.
So you might want to get today's date (by using
date command) and search (using grep) for today's
date from the find output. This also handles files
created on same date one or more years back.

- Biswajit
:-)
Muthukumar_5
Honored Contributor

Re: scripts help

Try the script as,

for file in `find . ! -name . -ctime -1`
do
if [[ $(ls -s $file | awk '{ print $1 }') -gt 0 ]]
then
# operation $file
echo $file
fi
done

HTH.
Easy to suggest when don't know about the problem!
Sir T S S
Advisor

Re: scripts help

thanks for the help./