博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
查找文件
阅读量:3941 次
发布时间:2019-05-24

本文共 993 字,大约阅读时间需要 3 分钟。

查找文件

• 根据预设的条件递归查找对应的文件– find [目录] [条件1] [-a|-o] [条件2] ...-a多个条件同时满足            -o满足一个条件– 常用条件表示:  -type 类型(f文件、d目录、l快捷方式)  -name "文档名称"  -size +|-文件大小(k、M、G)  -user 用户名
-type 类型(f文件、d目录、l快捷方式)find  /boot/  -type l       查找快捷方式 find /boot/ -type d         查找是目录find /boot/ -type f         查找是文件
-name "文档名称"find /boot/ -name  "vm*"    以vm开头的查找出来
-size +|-文件大小(k、M、G)find /boot/ -size +10M      查找boot大于10M的查找出来
-user 用户名find /  -user student       查找用户所有者创造的文档(目录和文件)
根据名称查找,忽略大小写   -inamefind /etc/ -iname "PASSWD"  忽略大小写查找
根据所属组进行查找  -groupfind /home/ -group student查找用户所属组创造的文档(目录和文件)
限制目录查找的深度(最大层数)   -maxdepthfind /etc/  -maxdepth 1    -name  "*.conf"在etc下以.conf结尾的父目录和子目录
根据文件修改时间(所有的时间,都是过去时间)  -mtime  -mtime +10   #10天之前的文档  -mtime -10   #最近10天之内的文档 find /var/log/ -mtime +1000find /var/log/ -mtime +90    cat -n /var/log/messages
使用find命令的 -exec 操作find .. .. -exec 处理命令 {} \;优势:以 {} 代替每一个结果,逐个处理,遇 \; 结束find /etc -name  "*tab"find /etc -name  "*tab"  -exec  cp  {}  /opt  \;ls  /opt

转载地址:http://krnwi.baihongyu.com/

你可能感兴趣的文章
有效的软件测试度量
查看>>
机器学习界大牛林达华推荐的书籍
查看>>
path变量备份
查看>>
Lesson2.2 & 2.3 Maya command reference & quick help
查看>>
lesson 2.4 - Converting MEL Commands to Python
查看>>
Lesson3.2 variables
查看>>
3.4.2 - Operators & 3.4.3 division and truncation
查看>>
3.7.1 - Strings
查看>>
3.7.4 - Indexing and Slicing Strings
查看>>
3.7.5 - Modifying Strings
查看>>
3.7.6 - String Methods
查看>>
3.8 - Using the Print Function
查看>>
3.9.1 - Lists in Python
查看>>
3.9.2 - Lists - Adding and Removing Objects
查看>>
3.9.3 - Sorting Lists
查看>>
3.10 - Maya Commands: ls
查看>>
3.11 - Dictionaries in Python
查看>>
3.12 - Tuples in Python
查看>>
4.4 - For Loops
查看>>
4.2.2 - Logical and/or Operators
查看>>