current date modified file

Hi ,

In my directory , i have many days file but i want to see all those which are of todays date.
i tried this but it gives all the files

mtime -0 |ls -ltr

I tried the below option as well.

19635   find -iname "*.LOG" -mtime
19636   ls -ltr *.LOG -mtime -1
19637   ls -ltr *.LOG mtime -0

nothing worked.

Can you suggest me how to list all the current days file and want to move them current day file to new directory

I assume you mean a calendar day, starting at midnight.
The format for the date in the touch command is YYYYMMDDHHMI; the date command format string gives you midnight when run any time during the day

 cd /log/directory
 # be sure to make the new day's directory before all this below
 touch -t `date +%Y%m%d0000` dummy
 find . -newer dummy -type f  |
 while read fname
 do
     mv $fname [new directory name goes here]    
 done

Hi ,

Many thanks it is working. I need few clarification here , what does touch -t is doing here. scripts looks like can be run any day and it will bring the data for current day. can it be modied according to the need let say once in month if i want to move all the file for yesterday or may be 3 days back one. how can we amend here in this file.

Much appreciated.

Thanks

Rajesh

touch modifies the file's timestamp.
Look here

UNIX man pages : touch ()

Please post what Operating System and version you have. Do you have the GNU date command?

There is a FAQ on dates here:
http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html

HI ,

My os is sun solaris 10 64 bit.

We guess that you don't have the GNU date command, therefore please refer to the FAQ for date arithmetic.

Hi

My OS is solaris 64 bit 10, I have many files in a logs directory where we recive 40-50 logs every day. i have last 20 days file present in this directory. I want to move each day file to a particulaar directory whose name is appended with the date of file.

eg

1.txt  file date 31-jul-2012
2.txt  file date 31-jul-2012
3.txt  file date 01-Aug-2012
 

then create a directory for old files of 31-jul RIO_31-Jul-2012 and move them and like wise for 01-aug files.

I have written a scripts which is running fine for current date but i don't know how t modify it to accomdate old date.

---------- Post updated at 10:55 AM ---------- Previous update was at 10:54 AM ----------

My scripts is as below

NEWDIR=RIO_31-Jul-2012
 mkdir /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 cd /var/opt/ers/logs/rio
 touch -t `date +%Y%m%d0000` dummy
 find . -newer dummy -type f  |
 while read fname
 do
     mv $fname /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 done

Thanks