On Wed 01 Dec 2004 at 22:16:12, [EMAIL PROTECTED] said:
> I have a bunch of file names blah001.txt, blah002.txt, etc. I want to
> replace with blah1.txt, blah2.txt, etc. in sum, I want to remove leading
> zeros off all the filenames in the directory.
> 
> how can I use perl to do that?

Bah!  Perl is for the weak!  For file manipulation, bash is the only tool
you need:

    for f in blah*; do mv -f $f `echo $f | sed 's/0*\([1-9]\)/\1/'`; done

Or if you have 'extglob' enabled (and every bash user worth his salt does)
it's even easier:

    for f in blah*; do mv -f ${f/#blah*(0)/blah}; done

Use 'shopt -s extglob' to turn on extglob.

-- 
Soren Harward <[EMAIL PROTECTED]> -- http://theboard.byu.edu/
"Americans are always attempting to run away from conformity, but
unfortunately they always start running in the same direction."
                                                  -- Art Buchwald

Attachment: signature.asc
Description: Digital signature

--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to