* [gentoo-user] date-specific cp/mv
@ 2006-09-28 16:16 maxim wexler
2006-09-28 16:24 ` darren kirby
` (3 more replies)
0 siblings, 4 replies; 17+ messages in thread
From: maxim wexler @ 2006-09-28 16:16 UTC (permalink / raw
To: gentoo-user
Hi group,
I'd like to be able to cp or mv certain files from a
dir according to their timestamp.
man cp mentions the '--preserve' option but I don't
think that's what I need.
Does somebody know of some sort of script or perl or
python pass that'll do it?
-Maxim
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] date-specific cp/mv
2006-09-28 16:16 [gentoo-user] date-specific cp/mv maxim wexler
@ 2006-09-28 16:24 ` darren kirby
2006-09-28 16:41 ` Dave V
2006-09-28 16:27 ` Trey Gruel
` (2 subsequent siblings)
3 siblings, 1 reply; 17+ messages in thread
From: darren kirby @ 2006-09-28 16:24 UTC (permalink / raw
To: gentoo-user
quoth the maxim wexler:
> Hi group,
>
> I'd like to be able to cp or mv certain files from a
> dir according to their timestamp.
Have a look at find. You can whip up a one-liner using the -atime, -mtime
or -ctime tests (depending on your intent) and use -exec to do the cp or
mv...
> -Maxim
-d
--
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] date-specific cp/mv
2006-09-28 16:16 [gentoo-user] date-specific cp/mv maxim wexler
2006-09-28 16:24 ` darren kirby
@ 2006-09-28 16:27 ` Trey Gruel
2006-09-28 16:47 ` Alan McKinnon
2006-09-29 5:46 ` [gentoo-user] " Alexander Skwar
3 siblings, 0 replies; 17+ messages in thread
From: Trey Gruel @ 2006-09-28 16:27 UTC (permalink / raw
To: gentoo-user
On 9/28/06, maxim wexler <blissfix@yahoo.com> wrote:
> I'd like to be able to cp or mv certain files from a
> dir according to their timestamp.
>
> man cp mentions the '--preserve' option but I don't
> think that's what I need.
>
> Does somebody know of some sort of script or perl or
> python pass that'll do it?
something akin to:
find <srcdir> -type f -mmin 5 -exec cp {} <destdir> \;
will copy all files in srcdir that have been modified within 5 minutes
to destdir. check the find man page for other ways of checking the
files or restricting how far find will recurse, etc..
--
Trey
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] date-specific cp/mv
2006-09-28 16:16 [gentoo-user] date-specific cp/mv maxim wexler
2006-09-28 16:24 ` darren kirby
2006-09-28 16:27 ` Trey Gruel
@ 2006-09-28 16:47 ` Alan McKinnon
2006-09-29 2:00 ` maxim wexler
2006-09-29 5:46 ` [gentoo-user] " Alexander Skwar
3 siblings, 1 reply; 17+ messages in thread
From: Alan McKinnon @ 2006-09-28 16:47 UTC (permalink / raw
To: gentoo-user
On Thursday 28 September 2006 18:16, maxim wexler wrote:
> Hi group,
>
> I'd like to be able to cp or mv certain files from a
> dir according to their timestamp.
>
> man cp mentions the '--preserve' option but I don't
> think that's what I need.
>
> Does somebody know of some sort of script or perl or
> python pass that'll do it?
use find with the time-related options and -exec. To move
everything in ~/mystuff that's older than 3 days (72 hours) to
~/backup, you could use
find ~/mystuff -type f -mtime 72 -exec mv {} ~/backup \;
find has many options related to searching by time (hours,
minutes, etc) and you can select by atime, ctime or mtime. It's
all in the man page
alan
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] date-specific cp/mv
2006-09-28 16:47 ` Alan McKinnon
@ 2006-09-29 2:00 ` maxim wexler
2006-09-29 4:43 ` Daniel Iliev
2006-09-29 5:47 ` [gentoo-user] Re: date-specific cp/mv Alexander Skwar
0 siblings, 2 replies; 17+ messages in thread
From: maxim wexler @ 2006-09-29 2:00 UTC (permalink / raw
To: gentoo-user
> find has many options related to searching by time
> (hours,
> minutes, etc) and you can select by atime, ctime or
> mtime. It's
> all in the man page
I can't get it to work. I used -ctime, -mtime, -mmin.
The files were created on the 26th of this month using
abcde. All the other files in the dir are at least two
weeks old, so I gave it 72(hours) then 3(days) to grab
everything in the last three days then 96 and 4 just
to make sure. I gave it mmin with 4810(72*60 minutes)
and 5760(90*60). Every time nothing happens; nothing
is copied and no error message is generated. I gave it
relative dirs and absolute dirs. I used -type f and
-fstype <file-type>. Nothing.
-mw
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] date-specific cp/mv
2006-09-29 2:00 ` maxim wexler
@ 2006-09-29 4:43 ` Daniel Iliev
2006-09-29 16:34 ` [gentoo-user] date-specific cp/mv RESOLVED maxim wexler
2006-09-29 5:47 ` [gentoo-user] Re: date-specific cp/mv Alexander Skwar
1 sibling, 1 reply; 17+ messages in thread
From: Daniel Iliev @ 2006-09-29 4:43 UTC (permalink / raw
To: gentoo-user
maxim wexler wrote:
>> find has many options related to searching by time
>> (hours,
>> minutes, etc) and you can select by atime, ctime or
>> mtime. It's
>> all in the man page
>>
>
> I can't get it to work. I used -ctime, -mtime, -mmin.
> The files were created on the 26th of this month using
> abcde. All the other files in the dir are at least two
> weeks old, so I gave it 72(hours) then 3(days) to grab
> everything in the last three days then 96 and 4 just
> to make sure. I gave it mmin with 4810(72*60 minutes)
> and 5760(90*60). Every time nothing happens; nothing
> is copied and no error message is generated. I gave it
> relative dirs and absolute dirs. I used -type f and
> -fstype <file-type>. Nothing.
>
> -mw
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
I believe the right syntax is:
find /path/dir -type f -ctime -3
This should mean "show all files created for the last 3 days".
Use "-3" not "3"
--
Best regards,
Daniel
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* [gentoo-user] Re: date-specific cp/mv
2006-09-29 2:00 ` maxim wexler
2006-09-29 4:43 ` Daniel Iliev
@ 2006-09-29 5:47 ` Alexander Skwar
2006-09-29 16:27 ` maxim wexler
1 sibling, 1 reply; 17+ messages in thread
From: Alexander Skwar @ 2006-09-29 5:47 UTC (permalink / raw
To: gentoo-user
· maxim wexler <blissfix@yahoo.com>:
> I can't get it to work. I used -ctime, -mtime, -mmin.
How did you use it?
Alexander Skwar
--
Cold, adj.:
When the politicians walk around with their hands in their own pockets.
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] Re: date-specific cp/mv
2006-09-29 5:47 ` [gentoo-user] Re: date-specific cp/mv Alexander Skwar
@ 2006-09-29 16:27 ` maxim wexler
2006-09-29 18:35 ` [gentoo-user] " Alexander Skwar
0 siblings, 1 reply; 17+ messages in thread
From: maxim wexler @ 2006-09-29 16:27 UTC (permalink / raw
To: gentoo-user
>
> How did you use it?
$find ~/<music> (-type f, -fstype mp3) (-mtime, -mmin,
-ctime) (72, 3, 4810, whatever) -exec cp {}
~/<music-bkp> \;
And it never said "bad option" or "file not found".
-Maxim
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* [gentoo-user] Re: Re: date-specific cp/mv
2006-09-29 16:27 ` maxim wexler
@ 2006-09-29 18:35 ` Alexander Skwar
2006-09-29 19:43 ` Daniel Iliev
0 siblings, 1 reply; 17+ messages in thread
From: Alexander Skwar @ 2006-09-29 18:35 UTC (permalink / raw
To: gentoo-user
· maxim wexler <blissfix@yahoo.com>:
>> How did you use it?
>
> $find ~/<music> (-type f, -fstype mp3) (-mtime, -mmin,
> -ctime) (72, 3, 4810, whatever) -exec cp {}
> ~/<music-bkp> \;
Well, actually, I don't wonder that *this* command did not
work. That's not at all even *close* to legal syntax.
Alexander Skwar
--
To say that UNIX is doomed is pretty rabid, OS/2 will certainly play a role,
but you don't build a hundred million instructions per second multiprocessor
micro and then try to run it on OS/2. I mean, get serious.
-- William Zachmann, International Data Corp
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] Re: Re: date-specific cp/mv
2006-09-29 18:35 ` [gentoo-user] " Alexander Skwar
@ 2006-09-29 19:43 ` Daniel Iliev
2006-09-29 20:15 ` Richard Fish
2006-09-30 9:33 ` [gentoo-user] " Alexander Skwar
0 siblings, 2 replies; 17+ messages in thread
From: Daniel Iliev @ 2006-09-29 19:43 UTC (permalink / raw
To: gentoo-user
Alexander Skwar wrote:
> · maxim wexler <blissfix@yahoo.com>:
>
>
>>> How did you use it?
>>>
>> $find ~/<music> (-type f, -fstype mp3) (-mtime, -mmin,
>> -ctime) (72, 3, 4810, whatever) -exec cp {}
>> ~/<music-bkp> \;
>>
>
> Well, actually, I don't wonder that *this* command did not
> work. That's not at all even *close* to legal syntax.
>
>
>
> Alexander Skwar
>
Well, I think that by the parenthesis Mr. Wexler wanted to show he had
tried all the variations, not that it is the exact command. I was also
very pissed off when I had to discover that the "find manual page" isn't
very correct. It never made clear that "-ctime 3" means "now plus 3
days" and "-ctime -3" means "now minus 3 days".
--
Best regards,
Daniel
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] Re: Re: date-specific cp/mv
2006-09-29 19:43 ` Daniel Iliev
@ 2006-09-29 20:15 ` Richard Fish
2006-09-29 20:37 ` Daniel Iliev
2006-09-30 9:33 ` [gentoo-user] " Alexander Skwar
1 sibling, 1 reply; 17+ messages in thread
From: Richard Fish @ 2006-09-29 20:15 UTC (permalink / raw
To: gentoo-user
On 9/29/06, Daniel Iliev <danny@ilievnet.com> wrote:
> tried all the variations, not that it is the exact command. I was also
> very pissed off when I had to discover that the "find manual page" isn't
> very correct. It never made clear that "-ctime 3" means "now plus 3
> days" and "-ctime -3" means "now minus 3 days".
Well the man page does have this paragraph in it (emphasis added):
If you are using find in an environment where security is important
(for example if you are using it to seach directories that are writable
by other users), you should read the "Security Considerations" chapter
of the findutils documentation, which is called Finding Files and comes
with findutils. **That document also includes a lot more detail and
discussion than this manual page, so you may find it a more useful
source of information.**
So you can get better documentation from the info pages by running
"info find.info". If you want specifics on the time options:
# info find.info "Finding Files" "Time"
BTW, in programmer speak, "now plus 3 days" would be interpreted as 3
days in the future...which is _not_ how find works. To try and
clarify:
-mtime 2 -> files modified between 48 and 72 hours ago.
-mtime -2 -> files modified in the last 2 days...the period between 0
and 48 hours ago.
-mtime +2 -> files modified more than 48 hours ago
HTH,
-Richard
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] Re: Re: date-specific cp/mv
2006-09-29 20:15 ` Richard Fish
@ 2006-09-29 20:37 ` Daniel Iliev
2006-09-29 22:36 ` Richard Fish
0 siblings, 1 reply; 17+ messages in thread
From: Daniel Iliev @ 2006-09-29 20:37 UTC (permalink / raw
To: gentoo-user
Richard Fish wrote:
> On 9/29/06, Daniel Iliev <danny@ilievnet.com> wrote:
>> tried all the variations, not that it is the exact command. I was also
>> very pissed off when I had to discover that the "find manual page" isn't
>> very correct. It never made clear that "-ctime 3" means "now plus 3
>> days" and "-ctime -3" means "now minus 3 days".
>
> Well the man page does have this paragraph in it (emphasis added):
>
> If you are using find in an environment where security is
> important
> (for example if you are using it to seach directories that are
> writable
> by other users), you should read the "Security Considerations"
> chapter
> of the findutils documentation, which is called Finding Files
> and comes
> with findutils. **That document also includes a lot more
> detail and
> discussion than this manual page, so you may find it a more
> useful
> source of information.**
>
> So you can get better documentation from the info pages by running
> "info find.info". If you want specifics on the time options:
>
> # info find.info "Finding Files" "Time"
>
> BTW, in programmer speak, "now plus 3 days" would be interpreted as 3
> days in the future...which is _not_ how find works. To try and
> clarify:
>
> -mtime 2 -> files modified between 48 and 72 hours ago.
> -mtime -2 -> files modified in the last 2 days...the period between 0
> and 48 hours ago.
> -mtime +2 -> files modified more than 48 hours ago
>
> HTH,
> -Richard
Point taken! Thanks for the clarification, Richard!
--
Best regards,
Daniel
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [gentoo-user] Re: Re: date-specific cp/mv
2006-09-29 20:37 ` Daniel Iliev
@ 2006-09-29 22:36 ` Richard Fish
0 siblings, 0 replies; 17+ messages in thread
From: Richard Fish @ 2006-09-29 22:36 UTC (permalink / raw
To: gentoo-user
On 9/29/06, Daniel Iliev <danny@ilievnet.com> wrote:
> Richard Fish wrote:
> > -mtime -2 -> files modified in the last 2 days...the period between 0
> > and 48 hours ago.
>
> Point taken! Thanks for the clarification, Richard!
And just to show that this is really hard to describe correctly...I
screwed this one up. It should be:
-mtime -2 -> files modified since 2 days ago...the period between 48
hours ago and any point in the future.
;-)
-Richard
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* [gentoo-user] Re: Re: Re: date-specific cp/mv
2006-09-29 19:43 ` Daniel Iliev
2006-09-29 20:15 ` Richard Fish
@ 2006-09-30 9:33 ` Alexander Skwar
1 sibling, 0 replies; 17+ messages in thread
From: Alexander Skwar @ 2006-09-30 9:33 UTC (permalink / raw
To: gentoo-user
· Daniel Iliev <danny@ilievnet.com>:
> Alexander Skwar wrote:
>> · maxim wexler <blissfix@yahoo.com>:
>>>> How did you use it?
>>>>
>>> $find ~/<music> (-type f, -fstype mp3) (-mtime, -mmin,
>>> -ctime) (72, 3, 4810, whatever) -exec cp {}
>>> ~/<music-bkp> \;
>>>
>>
>> Well, actually, I don't wonder that *this* command did not
>> work. That's not at all even *close* to legal syntax.
> Well, I think that by the parenthesis Mr. Wexler wanted to show he had
> tried all the variations, not that it is the exact command.
Ah, I see. I was interested in the exact command, not something
which closely describes what he did.
> I was also
> very pissed off when I had to discover that the "find manual page" isn't
> very correct. It never made clear that "-ctime 3" means "now plus 3
> days" and "-ctime -3" means "now minus 3 days".
Yeah, this also took me a very long time to get used to. Also
it took me quite some time to understand, that "+3" and "3" isn't
the same.
Alexander Skwar
--
0 7 * * * echo "...Linux is just a fad" | mail billg@microsoft.com -s=
"And remember..."
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
* [gentoo-user] Re: date-specific cp/mv
2006-09-28 16:16 [gentoo-user] date-specific cp/mv maxim wexler
` (2 preceding siblings ...)
2006-09-28 16:47 ` Alan McKinnon
@ 2006-09-29 5:46 ` Alexander Skwar
3 siblings, 0 replies; 17+ messages in thread
From: Alexander Skwar @ 2006-09-29 5:46 UTC (permalink / raw
To: gentoo-user
· maxim wexler <blissfix@yahoo.com>:
> I'd like to be able to cp or mv certain files from a
> dir according to their timestamp.
Use "find" and "xargs".
Alexander Skwar
--
Any sufficiently advanced bug is indistinguishable from a feature.
-- Rich Kulawiec
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2006-09-30 9:41 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-28 16:16 [gentoo-user] date-specific cp/mv maxim wexler
2006-09-28 16:24 ` darren kirby
2006-09-28 16:41 ` Dave V
2006-09-28 16:27 ` Trey Gruel
2006-09-28 16:47 ` Alan McKinnon
2006-09-29 2:00 ` maxim wexler
2006-09-29 4:43 ` Daniel Iliev
2006-09-29 16:34 ` [gentoo-user] date-specific cp/mv RESOLVED maxim wexler
2006-09-29 5:47 ` [gentoo-user] Re: date-specific cp/mv Alexander Skwar
2006-09-29 16:27 ` maxim wexler
2006-09-29 18:35 ` [gentoo-user] " Alexander Skwar
2006-09-29 19:43 ` Daniel Iliev
2006-09-29 20:15 ` Richard Fish
2006-09-29 20:37 ` Daniel Iliev
2006-09-29 22:36 ` Richard Fish
2006-09-30 9:33 ` [gentoo-user] " Alexander Skwar
2006-09-29 5:46 ` [gentoo-user] " Alexander Skwar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox