File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -337,5 +337,41 @@ find . -path "./sk" -prune -o -name "*.txt" -print
337
337
find . -empty
338
338
```
339
339
340
+ #### 其它实例
341
+
342
+ ``` bash
343
+ find ~ -name ' *jpg' # 主目录中找到所有的 jpg 文件。 -name 参数允许你将结果限制为与给定模式匹配的文件。
344
+ find ~ -iname ' *jpg' # -iname 就像 -name,但是不区分大小写
345
+ find ~ ( -iname ' jpeg' -o -iname ' jpg' ) # 一些图片可能是 .jpeg 扩展名。幸运的是,我们可以将模式用“或”(表示为 -o)来组合。
346
+ find ~ \( -iname ' *jpeg' -o -iname ' *jpg' \) -type f # 如果你有一些以 jpg 结尾的目录呢? (为什么你要命名一个 bucketofjpg 而不是 pictures 的目录就超出了本文的范围。)我们使用 -type 参数修改我们的命令来查找文件。
347
+ find ~ \( -iname ' *jpeg' -o -iname ' *jpg' \) -type d # 也许你想找到那些命名奇怪的目录,以便稍后重命名它们
348
+ ```
349
+
350
+ 最近拍了很多照片,所以让我们把它缩小到上周更改的文件
351
+
352
+ ``` bash
353
+ find ~ \( -iname ' *jpeg' -o -iname ' *jpg' \) -type f -mtime -7
354
+ ```
355
+
356
+ 你可以根据文件状态更改时间 (ctime)、修改时间 (mtime) 或访问时间 (atime) 来执行时间过滤。 这些是在几天内,所以如果你想要更细粒度的控制,你可以表示为在几分钟内(分别是 cmin、mmin 和 amin)。 除非你确切地知道你想要的时间,否则你可能会在 + (大于)或 - (小于)的后面加上数字。
357
+
358
+ 但也许你不关心你的照片。也许你的磁盘空间不够用,所以你想在 log 目录下找到所有巨大的(让我们定义为“大于 1GB”)文件:
359
+
360
+ ``` bash
361
+ find /var/log -size +1G
362
+ ```
363
+
364
+ 或者,也许你想在 /data 中找到 bcotton 拥有的所有文件:
365
+
366
+ ``` bash
367
+ find /data -owner bcotton
368
+ ```
369
+
370
+ 你还可以根据权限查找文件。也许你想在你的主目录中找到对所有人可读的文件,以确保你不会过度分享。
371
+
372
+ ``` bash
373
+ find ~ -perm -o=r
374
+ ```
375
+
340
376
341
377
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
You can’t perform that action at this time.
0 commit comments