linux查找如何忽略目录

我使用下列语句查找某个目录的大文件:

find . -type f -exec ls -s {} \; | sort -n -r | head -5

但是如果我想排除其中的目录: .git/,应该加什么呢?

阅读 7k
2 个回答

一般的,过滤隐藏文件

find . -not -path '*/\.*'

文件大小排序:

find . -type f  | xargs du | sort -rn | head

合起来:

find . -not -path '*/\.*' -type f | xargs du | sort -rn | head
find . -path ./.git -prune -o -type f -exec ls -s {} \; | sort -n -r | head -5
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题