Dealing with multiple files

Korn Shell

I have hundreds of small files like below created every day. A midnight cron job moves them to the location /u04/temp/logs

But sometimes I have to manually move these files based a certain dates or time.

I have two basic requirements

1.Using mv command I want to move all .dat files generated on July 11th to /u04/temp/logs . How can I do that ?

  1. Using mv command I want to move all .dat files generated on 12th of July between 13:00 and 18:30? Because of the BETWEEN requrement, I don't think I can use the find command with mtime or mmin?

ls -lrt output

-rw-r----- 1 aptusr dba 44133888 Jul 11 15:58 paxlcp_33861.dat
-rw-r----- 1 aptusr dba 44324864 Jul 11 16:03 paxlcp_33862.dat
-rw-r----- 1 aptusr dba 44285952 Jul 11 16:08 paxlcp_33863.dat
-rw-r----- 1 aptusr dba 44451840 Jul 11 16:14 paxlcp_33864.dat
-rw-r----- 1 aptusr dba 44388864 Jul 11 16:19 paxlcp_33865.dat
-rw-r----- 1 aptusr dba 44197888 Jul 11 16:24 paxlcp_33866.dat
-rw-r----- 1 aptusr dba 44388352 Jul 11 16:30 paxlcp_33867.dat
-rw-r----- 1 aptusr dba 44098560 Jul 11 16:35 paxlcp_33868.dat
-rw-r----- 1 aptusr dba 44222976 Jul 11 16:40 paxlcp_33869.dat
.
.
.
.
-- Snipped output
-rw-r----- 1 aptusr dba 44370944 Jul 12 17:36 paxlcp_35480.dat
-rw-r----- 1 aptusr dba 44185600 Jul 12 17:41 paxlcp_35481.dat
-rw-r----- 1 aptusr dba 44482048 Jul 12 17:46 paxlcp_35482.dat
-rw-r----- 1 aptusr dba 44135936 Jul 12 17:51 paxlcp_35483.dat
-rw-r----- 1 aptusr dba 44394496 Jul 12 17:56 paxlcp_35484.dat
-rw-r----- 1 aptusr dba 45940224 Jul 12 18:01 paxlcp_35485.dat
-rw-r----- 1 aptusr dba 44166656 Jul 12 18:06 paxlcp_35486.dat
-rw-r----- 1 aptusr dba 44468224 Jul 12 18:11 paxlcp_35487.dat
-rw-r----- 1 aptusr dba 44120064 Jul 12 18:17 paxlcp_35488.dat
-rw-r----- 1 aptusr dba 44072448 Jul 12 18:23 paxlcp_35489.dat

mv /u04/temp/logs/

I don't know if you want to be able to enter a specific time in a script, otherwise you can use find with "between" by combining two time conditions, like

find . -mtime +1h30m -mtime -4h -print

That will find all files in current directory modified between 1 and a half hour ago and 4 hours ago.

Try this,

find . -type f -newermt 2012-07-11 ! -newermt 2012-07-12 | xargs mv /u04/temp/logs