[ale] xargs w/ tr

David S. Jackson dsj at sylvester.dsj.net
Sat Jan 4 13:15:37 EST 2003


On Fri, Jan 03, 2003 at 04:53:49PM -0500 Fletch <fletch at phydeaux.org> wrote:
>     David> Like using xargs to set variable names, something like
>     David> whatever|xargs -J % name=% newname=`echo $name|tr A-Z a-z`
> 
> 
>         That's still not going to work because the backtics will be
> expanded before xargs ever sees them.

right you are.

> ... | rename 'y/A-Z/a-z/'

I'm on a bsd box at the moment; I'll have to install rename.  

> #!/usr/bin/perl -w
> # rename - Larry's filename fixer
> $op = shift or die "Usage: rename expr [files]\n";
> chomp(@ARGV = <STDIN>) unless @ARGV;
> for (@ARGV) {
>     $was = $_;
>     eval $op;
>     die $@ if $@;
>     rename($was,$_) unless $was eq $_;
> }

Perl makes stuff looks so easy and succinct.  It's almost not fair.  :-)
There's probably even a perl library for making coffee or poaching eggs.
Amazing.

I wonder if I should just switch over to perl for everything.  If
there's one language that could just about do everything...

-- 
David S. Jackson                        dsj at dsj.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
When I was crossing the border into Canada, they
asked if I had any firearms with me.  I said, "Well,
what do you need?" -- Steven Wright
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list