[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: greg.freemyer at gmail.com (Greg Freemyer)
- Date: Fri, 6 Apr 2007 15:37:46 -0400
All,
I need to do a rename on a bunch of sequential files from something like:
output-000001.pgm
output-000002.pgm
output-000003.pgm
...
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", counter)
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.
Thanks
Greg
--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century