tr from the command line

Kevin Buettner plug-discuss@lists.plug.phoenix.az.us
Tue, 14 May 2002 18:01:49 -0700


On May 14,  8:40pm, Carl Parrish wrote:

> I've got a lot of files called *_log.  I want to change them all to
> *.log.  I *think* I want to use the tr command.  Can anyone give me
> the syntax?  my undertanding from the info and man files isn't
> working. 

Maybe something like this?

for f in *_log; do mv $f `echo $f | tr _ .`; done

However, I think using sed in this case might be better:

for f in *_log; do mv $f `echo $f | sed -e 's/_log$/.log/'`; done

Kevin