tags:

views:

112

answers:

3

I need to find files which have been in the folder Wastebasket exactly one minute. The files have been moved all over my computer to the folder.

I run the following unsuccessfully

find -atime n1m .

I get all my files in the directory by the command, even ones which I just created. It seems that the option -atime is not correct.

How can you find files which access time is one minute?

+2  A: 

Drop the n. The n in the manpage stands for a number.

find -atime 1m .
Chris Lutz
@Chris: Your command should work. However, I did not manage to get it work by touching a file and then running your command.
Masi
From the man: File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.'fractional part is ignored'I think that might be why
jim
@Lou - That is only if no units are specified. '1m' is different from '1'. The 'm' specifies minutes as the unit, so it checks 1 minute. From the man: If units are specified, this primary evaluates to true if the difference between the file last access time and the time find was started is exactly n units.
Chris Lutz
Yea I saw the m notation and usually use it in practice but never read the man that in depth. +1 for teaching me something
jim
+1  A: 

Since you've mentioned you're using zsh, I might as well suggest a zsh-specific answer. To find all files with access time of minute or less ago, you can use the command:

$> ls *(.am-1)
sykora
@sykora: Where can you get the documentation for such great commands? I did not find your parameters at $man find in my Z shell.
Masi
This particular command I lifted in part from the zsh reference card: http://www.bash2zsh.com/zsh_refcard/refcard.pdf . You can also search the zsh wiki, the zshlovers man page, and the other man pages. And google, of course.
sykora
+1  A: 

I think you're looking for

find -amin 1

'n' is just a variable that you replace with a number.

+n eg +1 means greater
n eg 1 means exactly
-n eg -1 means less than

jim
@Lou: Thank you for your answer! Your command works well in my Ubuntu.
Masi