OT: catch the bash error?

Hi All,

I wanted to do a mass rename of "Apple.*" to "Mac.*" with
bash and I could not figure out the error.

I eventually did find it and I have to blame Perl for it!

Chuckle.

for F in Apple*; do $G=$(echo $F | sed -e 's/^Apple/Mac/'); mv $F $G; 
echo "$F --> $G"; done

Did you catch the error?  I stared and stared at it for about
ten minutes.

-T










It is "do G=" not "do $G="
0
ToddAndMargo
8/4/2018 5:08:33 AM
perl.perl6.users 1003 articles. 0 followers. Follow

4 Replies
19 Views

Similar Articles

[PageSpeed] 0

--000000000000dbe2ce057297a01a
Content-Type: text/plain; charset="UTF-8"

I'm really not very good at bash scripting (because I would almost always
to such things in Perl), but I guess that the initial $G is an error (there
should not be a $ sigil).


2018-08-04 7:08 GMT+02:00 ToddAndMargo <ToddAndMargo@zoho.com>:

> Hi All,
>
> I wanted to do a mass rename of "Apple.*" to "Mac.*" with
> bash and I could not figure out the error.
>
> I eventually did find it and I have to blame Perl for it!
>
> Chuckle.
>
> for F in Apple*; do $G=$(echo $F | sed -e 's/^Apple/Mac/'); mv $F $G; echo
> "$F --> $G"; done
>
> Did you catch the error?  I stared and stared at it for about
> ten minutes.
>
> -T
>
>
>
>
>
>
>
>
>
>
> It is "do G=" not "do $G="
>

--000000000000dbe2ce057297a01a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I&#39;m really not very good at bash scripting (becau=
se I would almost always to such things in Perl), but I guess that the init=
ial $G is an error (there should not be a $ sigil).</div><div><br></div></d=
iv><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">2018-08-04 7:0=
8 GMT+02:00 ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"mailto:ToddAndMar=
go@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt;</span>:<br><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex">Hi All,<br>
<br>
I wanted to do a mass rename of &quot;Apple.*&quot; to &quot;Mac.*&quot; wi=
th<br>
bash and I could not figure out the error.<br>
<br>
I eventually did find it and I have to blame Perl for it!<br>
<br>
Chuckle.<br>
<br>
for F in Apple*; do $G=3D$(echo $F | sed -e &#39;s/^Apple/Mac/&#39;); mv $F=
 $G; echo &quot;$F --&gt; $G&quot;; done<br>
<br>
Did you catch the error?=C2=A0 I stared and stared at it for about<br>
ten minutes.<br>
<br>
-T<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
It is &quot;do G=3D&quot; not &quot;do $G=3D&quot;<br>
</blockquote></div><br></div>

--000000000000dbe2ce057297a01a--
0
perl6
8/4/2018 8:14:07 AM
>>     It is "do G=" not "do $G="
>> 
>> 

On 08/04/2018 01:14 AM, Laurent Rosenfeld via perl6-users wrote:
> I'm really not very good at bash scripting (because I would almost 
> always to such things in Perl), but I guess that the initial $G is an 
> error (there should not be a $ sigil).

That was it.  Perl has got me so trained that I did not even
realize my mistake for quite some time.

Chuckle
0
ToddAndMargo
8/5/2018 4:19:48 AM
That's the problem with using multiple related-but-not-identical
languages. If you aren't completely on the ball, one of the others may
grab you by the ankle and trip you.

On 8/5/18, ToddAndMargo <ToddAndMargo@zoho.com> wrote:
>>>     It is "do G=" not "do $G="
>>>
>>>
>
> On 08/04/2018 01:14 AM, Laurent Rosenfeld via perl6-users wrote:
>> I'm really not very good at bash scripting (because I would almost
>> always to such things in Perl), but I guess that the initial $G is an
>> error (there should not be a $ sigil).
>
> That was it.  Perl has got me so trained that I did not even
> realize my mistake for quite some time.
>
> Chuckle
>
0
1parrota
8/5/2018 1:51:58 PM
On 08/05/2018 06:51 AM, Parrot Raiser wrote:
> That's the problem with using multiple related-but-not-identical
> languages. If you aren't completely on the ball, one of the others may
> grab you by the ankle and trip you.

I have been converting a large program on mine over from
Perl 5 to Perl6.  I have "finally" stopped mixing p5 and p6
together and can spot the differences pretty rapidly.
When I finish this conversion, I will only have one
p5 program left to maintain, but that can't be converted
to p6 as the ftp module in p6 is broken.

P5's sub declarations are tragic.  P6's is a wonderful
clean up.

I like the way p6 does regex's better too.

      $NewRev ~~ s/ "\<" .* //;

I like the way I can put spaces in the first part so
I can easily understand what I am looking for.

And I like the second part being literal so I
do have to escape the moon.
0
ToddAndMargo
8/5/2018 7:48:22 PM
Reply: