Linux FAQ : find 用法

https://medium.com/@berrybearw/linux-faq-find-用法-a176c5e63001

find 用法

find 目录 参数 条件
介绍 : 找寻档案或目录在哪里
格式 find 目录 参数 条件
常用 找寻当下目录档案
find (找寻) . (当下所在目录) -name (档案名称为) 123
find . -name '123'
模糊搜寻请搭配 正规表达式
找寻当下目录结尾是 123 档案
find . -name '*123'

参考 :

https://blog.gtwang.org/linux/unix-linux-find-command-examples/

https://stackoverflow.com/questions/4210042/how-do-i-exclude-a-directory-when-using-find

find . -type d 'xxx*'

参数

目录搜寻层数maxdepth 第几层find . -maxdepth 1忽略特定目录-not -path 目录find . -name '123' -not -path './usr/*'path 目录 -prune -ofind . -path ./usr -prune -o -name '123'-user 使用者find . -user topstd -name '*' -exec ls -l {} \;排除 使用者find . ! -user topstd -name '*' -exec ls -l {} \;-szie 大小find . -size +10k小于 10 kfind . -size -10k

https://stackoverflow.com/questions/38843212/how-to-use-echo-with-find-in-bash

The shell redirection, >> is being done at first, a file named {} is being created before even the find starts and the strings (the number of files are in there) are being written to the file {}.

You need:

find . -type f -exec bash -c 'echo "This file found" >>"$1"' _ {} \;

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章