'basename' can be a useful tool: amit0 ~ # cd /tmp amit0 tmp # ls *.tif 1.tif 2.tif amit0 tmp # for f in *.tif;do echo convert $f "$(basename $f \.tif).jpg";done convert 1.tif 1.jpg convert 2.tif 2.jpg
Though in this case, I think variable expansion is more elegant. basename strips the path from the tif's, which you probably don't want... HTH Amit On Sun, Dec 13, 2009 at 7:56 AM, Rick Welykochy <r...@praxis.com.au> wrote: > david wrote: > > $ for i in *.tif ; convert $i $i.jpg; done >> $ for i in $i.jpg ; do mv $i `echo $i | sed s/.tif//`; done >> >> Apart from specific examples, where do I look in the bash book for a >> better >> way to remove the <.tif> part of the output filename, or other such >> substitutions? >> > > OTTOMH, there are some interpolation constructs in bash to help with this: > > ${VARIABLE#string} > ${VARIABLE##string} > > ${VARIABLE%string} > ${VARIABLE%%string} > > and saving "substitute" (best) for last: > > ${VARIABLE/from/to} > > in your case perhaps: mv $i ${i/.tif/} > > All of the above are described somewhere in the 4000+ pages > of the bash manual ;) > > cheers > rickw > > > > > > > > -- > _________________________________ > Rick Welykochy || Praxis Services > > I was born in 1992. You have been negotiating all my life. > You cannot tell us that you need more time. > -- Christina, 17, Solomon Islands - threatened by sea level rise > > -- > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html > -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html