From: Atropo on
On 3 jul, 10:59, Jon LaBadie <jlaba...(a)aXcXm.org> wrote:
> Atropo wrote:
> > On 2 jul, 17:30, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
> >> Atropo <lxvasq...(a)gmail.com> writes:
> >>> I took this script suggested by Stephane CHAZELAS
> >>> find . -name "* .txt" -exec sh -c 'file=$1; exec mv "${file}" "${file
> >>> % .txt}.txt"' {} {} \;
> >> I think some stray spaces have crept in there in addition to the newline
> >> which is at least obvious.
>
> >>> this was intended to rename files,  but i want create new files with
> >>> same name but another extension.
> >>> find . -type f -name PPpldate.jpg -exec sh -c  'file=$1; -exec touch "$
> >>> {file%.*}.png"' {} {} \;
> >>> ./tmp/PPpldate.pl: bad substitution
> >> Hmm.  There is some evidence that this is not what you typed.  Please
> >> use some cut and paste method so that you post exactly what was
> >> entered.
>
> >>> I guess is the last two  {}, but not sure, not enough documentation..
> >> No, they are fine.
>
> >> I'd do this:
>
> >>   find . -type f -name \*.jpg -exec sh -c 'touch "${1%.*}.png"' {} {} \;
>
> >> but please test it first by replacing touch with something like echo.
>
> >> --
> >> Ben.
>
> > Thanks  Ben.
>
> > i ran your suggestion and throws same errors
>
> >  find . -type f -name \*.jpg -exec sh -c 'touch "${1%.*}.png"' {} {}
> > \;
> > ./tmp/PPpldate.jpg: bad substitution
> > ./tmp/PPpldate2.jpg: bad substitution
>
> > only works if I take off the  %.*  ,   could be that it's specific for
> > ksh ?  and i am calling sh
>
> Your Solaris /bin/sh does not implement %.*.  Replace "sh -c" with "ksh -c"


Excellent Jon. that's what i was wondering. if ksh accept -c .
never find it. i was RTFM but it was ovelwhelming. Thanks
From: Geoff Clare on
Jon LaBadie wrote:

> Atropo wrote:
>>
>> find . -type f -name \*.jpg -exec sh -c 'touch "${1%.*}.png"' {} {}
>> \;
>> ./tmp/PPpldate.jpg: bad substitution
>> ./tmp/PPpldate2.jpg: bad substitution
>>
>> only works if I take off the %.* , could be that it's specific for
>> ksh ? and i am calling sh
>>
>
> Your Solaris /bin/sh does not implement %.*. Replace "sh -c" with "ksh -c"

A better solution would be for Atropo to change his PATH to one
that finds the POSIX conforming utilities before the historical ones.

E.g. PATH=$HOME/bin:$(getconf PATH):other_stuff

--
Geoff Clare <netnews(a)gclare.org.uk>