简体   繁体   English

递归查找30天或更长时间的文件或目录,但从特定目录开始搜索

[英]find files or directories that are 30 or more days old, recursively, BUT starting the search from specific directory

I have been searching but I cannot find a way to essentially do the following in 1 line at Linux, so as to find files and directories that are more than 30 days old, starting the recursive search from script_dir: 我一直在搜索,但是我找不到在Linux的1行代码中进行以下操作的基本方法,以便查找超过30天的文件和目录,然后从script_dir开始进行递归搜索:

cd $script_dir
find . -type f -or -type d -mtime +30

If I do not do the cd to change to directory that I need to start searching from recursively (and use directly only the find), then, although I specify the script_dir at find the recursive search starts from the directory I am currently and NOT from the script_dir and beneath this directory. 如果我不执行cd切换到我需要从递归开始搜索的目录(并且仅直接使用查找),那么,尽管我在find处指定了script_dir,但递归搜索从我当前所在的目录开始,而不是从script_dir并在此目录下。 I want to do something like the following and even if I am currently at other directory than script_dir, the recursive search to start from script_dir: 我想执行以下操作,即使我当前不在script_dir的其他目录下,也要从script_dir开始进行递归搜索:

find $script_dir -type f -or -type d -mtime +30

Thank you. 谢谢。

In one line, you can do like this : 在一行中,您可以这样做:

cd /path/to/directory && find . -type f -or -type d -mtime +30

that do the search from the specified directory 从指定目录进行搜索

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 PowerShell 递归搜索目录和子目录中的所有文件? - How to recursively search all files in a directory and sub-directories using PowerShell? 以特定名称递归查找目录,然后清除它们 - Recursively find directories by a specific name and then clear them Shell - 递归查找子目录并将包含的文件复制到另一个目录 - Shell - Recursively find sub-directories and copy containing files to another directory 递归查找目录中的文件数 - Recursively find the number of files in a directory 如何从目录中递归找到的所有文件中搜索行匹配 - how to search for a line match from all files recursively found in a directory 从目录层次结构中的文件递归搜索和输出字符串 - Recursively search and output string from files in a directory hierarchy Bash 命令递归查找最新文件超过 3 天的目录 - Bash command to recursively find directories with the newest file older than 3 days 在 linux 中查找 30 天未读取的文件 - Find files not read for 30 days in linux 递归查找具有特定扩展名的文件 - Recursively find files with a specific extension 我想查找具有特定扩展名(.pfd、.xls、.ser 和 .csv)的文件,这些文件是 30 天以前的 - I want to find files with specific extensions (.pfd, .xls, . ser and .csv) which are 30 days older
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM