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 {} .{}
————————————————
版权声明:本文为优快云博主「朔珩轩」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/YHM07/article/details/42610615