您的位置:首页 > 运维架构 > Shell

[Bash] Find Files and Folders with `find` in Bash

2018-10-15 14:38 756 查看

find
 is a powerful tool that can not only find files but it can run a command on each matching file too. In this lesson, we’ll learn how to find all the images that match a pattern and run an image optimization tool on them.

 

FInd files:

find images/ -name "*.png"
find images/ -iname "*.png"  # case insensetive

 

Find folder:

find . -type d -name "images"  # find folder named images

 

Doing deleting: '-delete'

find dist/ -name "*.built.js" -delete

 

Run command after finding the matching:  '-exec'

find images/ -name "*.png" -exec pngquant {} \;

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: