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
精彩评论