[Wlug] Bash help
Theo Van Dinter
Thu, 18 Jul 2002 00:03:16 -0400
On Wed, Jul 17, 2002 at 08:47:35PM -0700, Tim Trachimowicz wrote:
> I have a bunch of files on a server that are in the
> format "filename_x.dat" and I need to rename them "filename.dat", i.e.
> strip to last two characters off the filename while maintaining the
Are they all "_x"? You could do something like:
for i in *_x.*; do mv -f $i `echo $i | sed -e 's/_x././'`; done
it would be more flexible to do in perl of course:
opendir(T,".") || die "can't open dir:$!";
next unless ( -f $_ );
($a,$b) = /^(.+)\.(.+)$/;
next unless ( $a && $b );
$a =~ s/..$//;
Warning: none of these have been tested, I just wrote them out so YMMV.
Randomly Generated Tagline:
"I'm at the age where food has taken the place of sex in my life. In
fact, I've just had a mirror placed over my kitchen table."
- Rodney Dangerfield