美文网首页
find排除一个或多个目录的方法

find排除一个或多个目录的方法

作者: Wood木木 | 来源:发表于2023-04-02 14:36 被阅读0次

find排除一个或多个目录的方法

百度就是垃圾,搜索结果千篇一律,错抄错。google一下,总结find排除某个目录的方法:
How to exclude a directory in find . command
Use the -prune switch. For example, if you want to exclude the misc directory just add a -path ./misc -prune -o to your find command:

寻找当前目录,排除misc目录,文件类型txt:

安卓find验证正常使用

find . -path ./misc -prune -o -name '*.txt' -print

Here is an example with multiple directories:

排除多个目录dir1,dir2,dir3的做法:

安卓下测试无效

find . -type d \( -path dir1 -o -path dir2 -o -path dir3 \) -prune -o -print

Here we exclude dir1, dir2 and dir3, since in find expressions it is an action that acts on the criteria -path dir1 -o -path dir2 -o -path dir3 (if dir1 or dir2 or dir3), ANDed with type -d.
最好加上-o print,打印。
Further action is -o print, just print.
下面这种情况没碰到过
If -prune doesn’t work for you, this will:

如果-prune 不好用,试试下面的。
安卓下测试无效

find -name "*.js" -not -path "./directory/*"

其他人的方法都没试过:

find / -name NameOfFile ! -path '*/Directory/*'
find . -name '*.js' -and -not -path directory
find . -type d -name proc -prune -o -name '*.js'
$ find ./ -type f -name "pattern" ! -path "excluded path" ! -path "excluded path"
$ find ./ -type f -name "*" ! -path "./.*" ! -path "./*/.*"
find . -type d \
-not \( -path */objects -prune \) \
-not \( -path */branches -prune \) \
-not \( -path */refs -prune \) \
-not \( -path */logs -prune \) \
-not \( -path */.git -prune \) \
-not \( -path */info -prune \) \
-not \( -path */hooks -prune \)

总结:

安卓系统下有效的命令有:

find . -type d -name proc -prune -o -name '*.js'
find . -path ./misc -prune -o -name '*.txt' -print

相关文章

  • 【rsync】使用rsync备份文件/目录并排除特定文件/目录

    Linux 下复制(cp)目录时排除一个或者多个目录的方法 cp 貌似没有排除目录的功能,可以使用 rsync 命...

  • 28 查找和放置系统文件

    find find 命令用于在一个或多个目录树中查找文件,搜索条件包括名称、时间戳或大小等。find 命令使用所有...

  • find多个目录

  • 复制目录排除一些目录不复制

    复制目录排除一些目录不复制 使用cp命令复制的时候,只能排除一个目录不被复制,如果想排除两个或者多个目录的话,就需...

  • find常用命令示例

    写在前面 在类unix操作系统中,find命令用于一个或多个目录树中查找文件。本文不会详细介绍find命令的用法,...

  • Linux常用命令 find 按规则查找某个文件或文件夹,包括子目录,这里的*表示0个或多个占位符,?表示一个占位...

  • linux find

    查找文件 find ./ -type f 查找目录 find ./ -type d 查找名字为test的文件或目录...

  • 12. Tweak练习

    1.定位目标文件 ps方法 find方法find -name sshd 固定目录中查找AppStore App全部...

  • beautiful soup解析

    find:匹配从上到下第一个出现的值 findAll方法 参数说明: tag:传入一个标签的名称或多个标签名组成的...

  • linux最常用的命令

    1、find 查找文件或目录 find / -size +204800k //在根目录下查找大于200MB的文件 ...

网友评论

      本文标题:find排除一个或多个目录的方法

      本文链接:https://www.haomeiwen.com/subject/cohcddtx.html