0
点赞
收藏
分享

微信扫一扫

linux find 命令的使用

书坊尚 2022-05-04 阅读 82
linux

一、背景

find命令是一个linux 常用的命令,作用是查找文件。由于对于查找文件需求的多样性,find 的使用实际上是非常复杂的,因此本文记录一下 find 命令的使用,方便自己查阅。

一些参考:
find 的基础用法
find 的 35 种命令

二、具体代码

# Find all directories named src
find . -name src -type d
# Find all python files that have a folder named test in their path
find . -path '*/test/*.py' -type f
# Find all files modified in the last day
find . -mtime -1
# Find all zip files with size in range 500k to 10M
find . -size +500k -size -10M -name '*.tar.gz'

# Delete all files with .tmp extension
find . -name '*.tmp' -exec rm {} \;
# Find all PNG files and convert them to JPG
find . -name '*.png' -exec convert {} {}.jpg \;

三、

举报

相关推荐

0 条评论