Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Find and copy files modified today

386 views
Skip to first unread message

Pete

unread,
Oct 15, 2008, 11:24:28 AM10/15/08
to
Hello,

I am trying to find and copy files modified today from one directory
to another. Something like:

cp find /dir1/P*.DAT -type f -mtime -1 /dir2/

Is there a way to combine the cp and find commands on a single line?
I don't think that there is, so instead I made a script to do this:

#!/bin/ksh
PATH1=find /dir1/P*.DAT -type f -mtime -1
PATH2=/dir2/
cp $PATH1 $PATH2

The individual lines do work, but when I try to run this as a script,
I get "/dir1/PTEST.DAT: This: not found." when it tries to do the
copy. I know I'm missing something obvious, but at this point google
has failed me...

Mike Marshall

unread,
Oct 15, 2008, 11:32:07 AM10/15/08
to
find /oneplace -type f -mtime -1 -exec cp {} /anotherplace \;

-Mike "hope you get an A... <g>"

nitinm...@gmail.com

unread,
May 15, 2013, 10:19:26 AM5/15/13
to
Hi,

Try below command
Go to that directory
find ./*.DAT -mtime +15 | cpio -pdumv ./new directory/

Gerard H. Pille

unread,
May 16, 2013, 1:41:41 PM5/16/13
to
nitinm...@gmail.com wrote:
> Hi,
>
> Try below command
> Go to that directory
> find ./*.DAT -mtime +15 | cpio -pdumv ./new directory/
>
>
> On Wednesday, October 15, 2008 4:24:28 PM UTC+1, Pete wrote:
>> Hello,
>>
>> I am trying to find and copy files modified today from one directory
>> to another. Something like:
>>


To find the files he modified almost 5 years ago, you'd rather

find ./*.DAT -mtime +1650 | cpio -pdumv ./new directory/

Not?
0 new messages