mtime option in find command
Hi,
What's the difference between the following commands: #find ~ -mtime 1 #find ~ -mtime -1 #find ~ -mtime +1 Below is what I got: Code:
#find ~ -mtime 1 |
Did you go through the man page clearly?
+n - for greater than n, -n - for less than n, n - for exactly n. |
The reference to the man page is brilliant, and here's one to
best practice; don't - I repeat - DON'T do your day to day stuff as root. Nasty habit. There's a good reason for the separation of powers, and a reason why you don't need to have tons of antivirus and ant-spyware programs in Linux; you're on the road to undoing this if you work as root all the time. Cheers, Tink |
Quote:
First, let's take the following case: #find ~ -mtime 1 It should mean: Files modified exactly 24 hours ago. One file of the returned results was: /root/.gconf/apps/panel/toplevels/bottom_panel/%gconf.xml Now consider the following: Code:
#date Also note in the following code the difference even in the dates: Code:
#find ~ -mtime 1 -exec ls -lt {} \; |
It is explained in the man page:
Code:
-atime n |
Quote:
Code:
#date |
Nope. In your example the find command gives some directories whose modification time is "1 day ago", then it passes the directory name to the ls command and the content of the directory is listed, regardless the modification time of every single file. To avoid that you can do either
Code:
find ~ -type f -mtime 1 -exec ls -l --time-style=iso {} \; Code:
find ~ -mtime 1 -exec ls -ld --time-style=iso {} \; |
Thanks colucix. You made it now really clear to me.
|
All times are GMT -5. The time now is 09:17 AM. |