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,
Code:
-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.
If you dont provide anything, then the current date will be picked up.
Vino
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
My unix version is IBM AIX Version 6.1
I tried google my requirement and found the below answer,
find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20"
But newer command is not working in AIX version 6.1 unix
I have given my requirement below:
Input:
atr files:
... (1 Reply)
I have file listed like below
-rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz
-rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz
-rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz
-rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz
-rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz
I... (5 Replies)
Hi,
I need a script that moves files based on date to a folder. The folder should be created based on file date. Example is :
Date file name
----- --------
Oct 08 07:39 10112012_073952.xls
Oct 09 07:39 10112012_073952.xls
Oct 10 07:39 ... (6 Replies)
I wan to view files in a directory of a specific date. For example a log directory has log files . I want to view the list of the files which were generated on 01-May-2011.
Is there any option/proces to perform it?? (1 Reply)
Hi
Howto view gzipped files with name file.gz.$DATE on a Solaris box (without unzipping first)
$ ls -lrt
total 4477
-rwxrwxr-x 1 oracle dba 569745 Apr 4 19:45 4_person2profileCon.txt.gz.04.04.11*
-rwxrwxr-x 1 oracle dba 3783 Apr 4 19:45... (4 Replies)
I have to write one script which will delete the files in the below passion.
If today is 17-Feb-2010 then the script delete only 17-JAN-2010 files from the directory.
Could you please help me, How will I delete the files when the year is leap year, if today is 30th Mar 2010 then how will... (1 Reply)
hi all,
here is the description to my problem.
input parameters: $date1 & $date2
based on the range i need to select the archived files from the archived directory and moved them in to working directory.
can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Hi Friends,
Can anyone help me with this:
To get the count of files that are existing in a directory created on a perticular date like in the example (01/08) .(having same pattern for the filename)
ex:
FileName Creted Date
FILE001 01/08/2007
FILE005 ... (6 Replies)
I am trying to write a shell script that will remove files in a directory based on the date. For instance, remove all files older than yesterday. Any ideas? (4 Replies)