[英]Bash , Find modified files for the last x days
Is there a way to find all files that have been modified the last x days from a specific directory?有没有办法从特定目录中找到过去 x 天修改过的所有文件? I have done this
我已经这样做了
find /home/user -iname "*.txt" -mtime -$x -print
but it shows the files from user not from the directory. find /home/user -iname "*.txt" -mtime -$x -print
但它显示来自用户的文件而不是来自目录的文件。
the content of the directory is:目录内容为:
total 8
-rw------- 1 danae danae 0 Jun 21 22:08 a
dr-x------ 2 danae danae 4096 Jun 30 10:56 d
-rw------- 1 danae danae 0 Jun 30 10:56 file
-rw-rw---- 1 danae danae 8 Jun 29 13:03 file2
-rw-rw---- 1 danae danae 0 Jun 21 22:06 file3
-rwxrwx--x 1 danae danae 0 Jun 21 22:06 file4
-r-------- 1 danae danae 0 Jun 21 22:07 file5
-rw-rw-r-- 1 danae danae 0 Jun 21 22:07 file6
The issue with your current command您当前命令的问题
find /home/user -iname "*.txt" -mtime -$x -print
Is "/home/user" which is telling find to always look in that directory.是“/home/user”,它告诉 find 总是在该目录中查找。
This should be replaced with the directory you want to look in. Or if you are doing this within a bash script first cd
to the directory and then use这应该替换为您要查看的目录。或者,如果您在 bash 脚本中执行此操作,请首先
cd
到该目录,然后使用
find . -iname "*.txt" -mtime -$x -print
Use .采用 。 to indicate the current directory:
指示当前目录:
find . -iname "*.txt" -mtime -$x -print
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.