[Gllug] perl script
Nick Mailer
nickm at positive-internet.com
Thu Aug 22 08:33:17 UTC 2002
On Thursday 22 August 2002 2:23 am, Mike Brodbelt wrote:
> On Thu, 2002-08-22 at 00:28, Nick Mailer wrote:
> > On Wednesday 21 August 2002 7:42 pm, Thom May wrote:
> > > Ber. forking perl for this is uber-overkill
> > > #!/bin/bash
> > > for i in *jpeg
> > > do
> > > new=$(echo $i|sed -e \
> > > 's#^\(.\)\(.\)\(.\)\(.\)\(.\)\(.*\)#\4\5\3\1\2\6#');
> > > mv $i $new;
> > > done
> > >
> > > Sorry about the nasty sed regexp - it's doable with bash direct but
> > > that is dark magic.
> > > -Thom
> >
> > So instead of forking one process of perl, you multiply-fork echo, sed
> > and mv. Well done, Mr Efficiency ;-)
>
> <pedant>
> Echo is a shell builtin in bash.
> </pedant>
>
> Mike.
<pedant++>
It is, but if /bin/echo is there (for other shells), the builtin is ignored..
nickm at barnet:~$ strace echo hello
execve("/bin/echo", ["echo", "hello"], [/* 21 vars */]) = 0
</pedant++>
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list