linux find使用

find [path ...] [expression]

find 命令使用举例

1、递归查找当前目录下所有文件

find . -print # print 可以省略

2、在目录/root 和 /home 下查找24h内没有更改的文件

find /root /home -mtime -1 -print

3、中/home下查找用户user的c程序及头文件

find /home -user user -name "*.[ch]* -print

4、将当前目录内的所有c程序及其头文件打包成tmp/mych.tar

tar -cv -f tmp/mych.tar `find . -name "*.[ch]" -type f -print`

5、在系统内查找用户或组不存在系统内的文件,文件名保存到tmp/noug

find / -nouser -or -nogroup -print | tee tmp/noug

6、在系统内查找用户或组均不是系统用户文件,删除它们( 慎重

find / -nouser -and -nogroup -exec rm {} \;  # 直接删除
find / -nouser -and -nogruop -ok rm {} \; # 删除时要确认

7、搜索当前目录下所有c文件

find ./ -name "*.c"

8、搜索当前目录下所有可执行文件

find ./ -perm /+x -type f 

9、不递归查找当前目录下所有文件并重命名为隐藏文件

find * -prune -type f | xargs -n1 -i{} mv {} .{}

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值