shell - linux查找如何忽略目录

查看:87
本文介绍了shell - linux查找如何忽略目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

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

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

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

解决方案

一般的,过滤隐藏文件

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

文件大小排序:

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

合起来:

find . -not -path '*/\.*' -type f | xargs du | sort -rn | head

这篇关于shell - linux查找如何忽略目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆