开发者

Recursively strip pattern from 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜