The "easy" way is to re-generate the list using
The "hard" way involves creating a set of regular expressions based on the current date/time and range. The "logwatch" utility has a perlmodule for doing exactly this sort of thing. Respond and I'll post more info.
The really hard way is to calculate the timestamp of the file in seconds based on the ls output and compare that to the current time minus 7 days of seconds (7*24*3600). It might not be as hard as I think, but it involves some straight coding (in Perl or awk) and probably lots of debugging.
I cant use the find command as i dont have the acces to the directory. The directory is accessed by ftp. I ftp to the remote machine and get the listing from the directory into this particular file. And then from this file I need to filter out files older than 7 days. So I think only way is to use the file.
In that case the timestamp method might be the way left I guess...
Hi Photon - I have little knowlegde about perl so I cant understand what your script does. I think its opening the directory and taking each file and checking for conditions. But can that be done with the contents of a file?
Hi ,
Can anyone help me how do perform below requirement in unix.
Step1:we will receive multiple files weekly with same name(as below) in a folder(In folder we will have other files also def.dat,ghf.dat)
Filenames:
1) abc_20171204_052389.dat
2)abc_20171204_052428.dat
DON'T modify... (23 Replies)
Hi All,
I want to list file of LAST 7 days acc. to its modified date and then concatinate.
I have following piece of code..
For concatenate
cat file1 file2 >> Output (For concatinating)
find . -mtime -7 -exec basename {} \; (list past files but it is including . file also)
Plz... (4 Replies)
Need to cpy those files which are created or modified in last 2 days.
bash$ ll -lrt
total 184
drwxr-xr-x 2 ons dce 256 Oct 12 06:58 files
-rw-r--r-- 1 ons dce 4313 Oct 14 06:06 cab.ksh
-rw-r--r-- 1 ons dce 6 Oct 14 07:03 Code.txt... (2 Replies)
hii all.
I have to get the date of the 7th day past from the current date.
if i give the current date as sep 3 then i must get the date as 27th of august.
can we get the values from the "cal" command.
cal | awk '{print $2}' will this type of command work.
actually my need is
if today is... (17 Replies)
I have a requirement which will select the files with a specific naming convention which got created in past 7 days in a specific directory.Lets say the directory is /data/XYZ and the file names follow the below nomenclature like Daily_File*.txt
I just need to create one CSV file which will... (12 Replies)
I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in.
How can this be done?? Find returns files that I do not want. (2 Replies)