More bash var chopping
Saturday, 15. April 2006, 14:38:12
http://my.opera.com/cpr/blog/show.dml/206175
Leaving basename() behind by chopping from the end of the variable-string:
Caveat: Sanitize underscore in pgfimage handle
Leaving basename() behind by chopping from the end of the variable-string:
$ for f in `ls *gif`;do echo $f; convert.exe $f ${f%.gif}.png;done
first_basic_admin.gif
first_comments_under_post.gif
first_congrats.gif
first_crud.gif
first_crud_layout.gif
first_custom_admin.gif
first_form_validation.gif
first_login.gif
first_routing.gif
first_welcome.gif
bash-3.00$ ls
first_basic_admin.gif first_crud.png first_login.gif
first_basic_admin.png first_crud_layout.gif first_login.png
first_comments_under_post.gif first_crud_layout.png first_routing.gif
first_comments_under_post.png first_custom_admin.gif first_routing.png
first_congrats.gif first_custom_admin.png first_welcome.gif
first_congrats.png first_form_validation.gif first_welcome.png
first_crud.gif first_form_validation.png symfony_favicon.png
$ for p in `ls *png`; do echo \\pgfdeclareimage\{${p%.png}\}{pictures/${p%.png}};done
Caveat: Sanitize underscore in pgfimage handle
IMG_0020.JPG 020.JPG IMG_x020.JPG
IMG_0021.JPG 021.JPG IMG_x021.JPG
IMG_0022.JPG 022.JPG IMG_x022.JPG
IMG_0023.JPG 023.JPG IMG_x023.JPG
bash-3.1$ for f in `ls *JPG`; do mv $f IMG_x${f#IMG_0}; done


