开发者

Recursively strip pattern from filename?

开发者 https://www.devze.com 2023-03-18 15:19 出处:网络
Is there a way for me to use the find command to recursively loop through a directory and strip a pattern from the filename?

Is there a way for me to use the find command to recursively loop through a directory and strip a pattern from the filename?

For example, if I have:

styles.css?c=123456

as a saved file, I would like to be able to loop through the files and match anything that has the wildcard *.css?* and then turn that styles.css?c开发者_JAVA百科=123456 into styles.css.


Try this:

find -type f -name '*.css*' -exec echo 'FILE="{}"; mv ${FILE} ${FILE%\?*} ' \; | bash
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号