Link to home
Start Free TrialLog in
Avatar of Oranew
Oranew

asked on

Unix copy some files to another directory

I have a logs directory where log files are getting copied for all the processes run during the day.
Users requested all the log files for February 20. There are more than 200 files generated for this date.
My question is how can I copy all the files generated on feb 20 to some other directory?  This is on unix sun solaris.
Thanks
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

touch -t 201602200000 /tmp/from
touch -t 201602202359 /tmp/to

cd /path/to/logdirectory
find . -type f -newer /tmp/from ! -newer /tmp/to | xargs -I{} cp {} /path/to/some/otherdirectory

rm /tmp/from /tmp/to

or

touch -t 201602200000 /tmp/from
touch -t 201602202359 /tmp/to

cd /path/to/logdirectory
find . -type f -newer /tmp/from ! -newer /tmp/to -exec cp {} /path/to/some/otherdirectory \+

rm /tmp/from /tmp/to
Avatar of Oranew
Oranew

ASKER

Thanks but I am not getting how this will get all the files only for Feb 20 and leave all the thousands of files from this directory? Also, I like to mention that the file names has  no date  but the files need to get from the time-stamp.

example:-
-rw-------   1 rpsoft    rpsoft       3685 Feb  20 08:45 apps_0892367_2T56TYZ.log
-rw-------   1 rpsoft    rpsoft       4422 Feb  20 09:22 apps_0892367_2T4FB62.log
-rw-------   1 rpsoft    rpsoft          7 Feb  20 14:30 rem_trace_cqrt_z23874_fvc_params.txt
-rw-------   1 rpsoft    rpsoft         73 Feb  20 14:30 rem_trace_cqrt_z23874_fvc.raw
-rw-------   1 rpsoft    rpsoft         99 Feb  20 14:30 rem_trace_cqrt_z23874_fvc.txt
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Oranew

ASKER

The question is not resolved but the admin require to close this question. I appreciate everyone for participating and try helping me resolving my question. Great helping team here.
Avatar of Oranew

ASKER

The question is not resolved but the admin require to close this question. I appreciate everyone for participating and try helping me resolving my question. Great helping team here.