[英]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.