I have a UNIX box where in files are created every 5 minutes. I need to write a shell script which will take in the date as parameter and return me all files created on that day. Also I will like it to show me only files which have a size greater than 0 i.e. non-empty files. how do I go abt this? I am new to UNIX
-d, --date=STRING
parse STRING and use it instead of current time
-F, --forward=SECONDS
Modify the time by going forward SECONDS seconds. For example,
touch -r foo -F 5 bar will make the file bar 5 seconds newer
than file foo.
-r, --reference=FILE
use this file's times instead of current time
That means create /tmp/OLD which has a timestamp provided by the user.
And then create /tmp/NEW which is exactly 24 hours newer compared to /tmp/OLD
And from man find,
-newer file
File was modified more recently than file. -newer is affected
by -follow only if -follow comes before -newer on the command
line.
-size n[bckw]
File uses n units of space. The units are 512-byte blocks by
default or if `b' follows n, bytes if `c' follows n, kilobytes
if `k' follows n, or 2-byte words if `w' follows n. The size
does not count indirect blocks, but it does count blocks in
sparse files that are not actually allocated.
The find script says -- find all files which are newer than /tmp/OLD but not /tmp/NEW and whose size is not zero.
There is a problem with this.. I am getting an error like "./Script.sh: cannot execute".. I dont know why it is happening.. CAn u help or suggest something?
This is the exact thing thats being shown (my file is called Script.sh):
$ Script.sh
ksh: Script.sh: not found
$ ./Script.sh
ksh: ./Script.sh: cannot execute
$ ls -lt
total 1
-rw-r----- 1 BTBDEV1 dba 227 Oct 5 13:46 Script.sh