linux shell之find高级点的用法

简介: linux shell之find高级点的用法

1  查找当前目录a.txt和b.txt文件,下面的o是or的意思, -iname是忽略大小写的意思(-o -iname)

find . -iname a.txt -o -iname b.txt


2 查找当前目录下的除了a.txt的文件(!)

find . ! -iname "a.txt"


3 查看当前目前下的目录(-type d)

find . -type d


4 查看当前目录下的普通文件(-type f)

find . -type f


5 查看当前目录下访问时间在一天内的文件(-atime)

find . -type f -atime -1


6 查看当前目录下访问时间在恰好一天的文件(-atime)

find . -type f -atime 1


7 查看当前目录下访问时间在恰好大于一天的文件(-atime)

find . -type f -atime +1


8 查看当前目录下访问时间在一分钟内的文件(-amin)

find . -type f -amin  -1



9 查看当前目录下访问时间在恰好一分钟的文件(-amin)

find . -type f -amin 1


10 查看当前目录下访问时间在恰好大于一分钟的文件(-amin)

find . -type f -amin +1


11 查看当前目录下访问时间在访问b.txt文件更加接近的文件,就是更加接近现在(-newer)

find . -type f -newer b.txt


12 查看当前目录下文件大小在2G之内的文件(-size)

find . -type f -size -2G


13 查看当前目录下文件大小恰好2M的文件(-size)

find . -type f -size 2M


14 查看当前目录下文件大小恰好2K的文件(-size)

find . -type f -size +2k


15 删除当前目录下面的*.txt文件(-delete)

find . -name *.txt -delete


16 给当前目录的sh文件添加权限(-exec {} \;)

find . -name "*.sh" -exec chmod 777 {} \;


17 给当前目录下的普通文件添加权限(-exec {} \;)

find . -type f -exec chmod 777 {} \;


18 复制当前目录的sh文件到./sh目录(-exec {} \;)

find . -name "*.sh" -exec cp {} ./sh/ \;


19 删除当前目录的sh文件(-exec {} \;)

find . -name "*.sh" -exec rm {} \;


20 查找当前目录下的不包含".git"目录下的普通文件(-prune修剪)

find . -type f -o -name "*.git" -prune


相关文章
|
19天前
|
Web App开发 Java Linux
Linux之Shell基本命令篇
Linux之Shell基本命令篇
Linux之Shell基本命令篇
|
4天前
|
编解码 Linux 数据安全/隐私保护
linux工具之curl与wget高级使用
linux工具之curl与wget高级使用
|
14天前
|
Linux
Linux 指令|date|cal|find|grep|热键
Linux 指令|date|cal|find|grep|热键
|
17天前
|
存储 Shell Linux
【攻防世界】unseping (反序列化与Linux bash shell)
【攻防世界】unseping (反序列化与Linux bash shell)
|
20天前
|
Shell Linux
【Linux】12. 模拟实现shell
【Linux】12. 模拟实现shell
27 2
|
26天前
|
Shell Linux
Linux的shell入门教程shell脚本入门教程
Linux的shell入门教程shell脚本入门教程
16 0
|
6天前
|
Java 关系型数据库 MySQL
Elasticsearch【问题记录 01】启动服务&停止服务的2类方法【及 java.nio.file.AccessDeniedException: xx/pid 问题解决】(含shell脚本文件)
【4月更文挑战第12天】Elasticsearch【问题记录 01】启动服务&停止服务的2类方法【及 java.nio.file.AccessDeniedException: xx/pid 问题解决】(含shell脚本文件)
33 3
|
1天前
|
弹性计算 运维 Shell
每天解析一个shell脚本(61)
【4月更文挑战第26天】shell脚本解析及训练(61)
12 3
|
1天前
|
弹性计算 运维 Shell
每天解析一个shell脚本(58)
【4月更文挑战第26天】shell脚本解析及训练(58)
67 0
|
1天前
|
弹性计算 Shell 数据安全/隐私保护
每天解析一个shell脚本(56)
【4月更文挑战第26天】shell脚本解析及训练(56)
13 0