Linux find命令学习记录

xiaoxiao2021-02-28  102

Linux find命令学习记录

find命令在linux中非常实用,可以帮助程序员高效率的找到想要的文件。

find 文件查找

查找特定的格式文件(以md和html文件为主) find . \(-name "*.md" -o -name "*.html"\) -print

此命令行会将所有的结果罗列出来

./xx.md ./html 查找所有非md文本 find . ! -name "*.md" -print 指定搜索深度 find . -maxdepth 1 -type f ##此处的f是指 file 按类型搜索 find . -type d -print ##此处的d是指 directory 列出最近7天被访问过的所有文件 find . -atime 7 -type f -print 找出大于2M的文件 find . -type f size +2M 找出具有可-rwxrwxr-x权限的所有文件 find . -type f -perm 775 -print 按用户查找 find . -type f -user name -print

find完成查找后的动作

删除所有swp文件 find . -type f -name "*.swp" -delete 将当前目录的下所有权限变更为temp find . -type f -user root -exec chown temp {} \; ## 如果不是在root下执行需要加上sudo
转载请注明原文地址: https://www.6miu.com/read-71073.html

最新回复(0)