[ale] Generating sequential files with leading zeros from bash

Michael B. Trausch fd0man at gmail.com
Fri Apr 6 15:44:39 EDT 2007


On Fri, 2007-04-06 at 15:37 -0400, Greg Freemyer wrote:

> 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) 


Similarly:

mbt at pepper:~$ echo $i
1
mbt at pepper:~$ printf '%07d\n' $i
0000001
mbt at pepper:~$ 

The printf command comes from GNU coreutils, by the way.

    -- Mike

--
Michael B. Trausch
                    fd0man at gmail.com
Phone: (404) 592-5746
                          Jabber IM:
                    fd0man at gmail.com
              fd0man at livejournal.com
Demand Freedom!  Use open and free protocols, standards, and software!
-------------- next part --------------
An HTML attachment was scrubbed...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part




More information about the Ale mailing list