[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Generating sequential files with leading zeros from bash
- Subject: [ale] Generating sequential files with leading zeros from bash
- From: dcox at icc.net (Cox, Danny)
- Date: Fri, 6 Apr 2007 15:46:24 -0400
- In-reply-to: <[email protected]>
- References: <[email protected]>
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of Greg
To: ale at ale.org
Sent: Friday, April 06, 2007 3:38 PM
To: Atlanta Linux Enthusiasts
Subject: [ale] Generating sequential files with leading zeros from bash
I need to do a rename on a bunch of sequential files from something
to a new name that has a different number of leading zeros and a
different starting number.
I now how to manage the counter, but how can I create a filename with
leading zeros from a bash script and a counter variable.
ie. in C code I would do sprintf(dest_filename, "prefix-%07d.pgm",
Is there something similar to sprintf in bash?
And to make the issue even more difficult, I would like the "07"
portion of the above to itself be variable. ie. Sometimes I will want
7 digits, other times 8, etc.
See "printf" the command. It should do what you want.