[Sig] Re: [Lvlug] Bash: how format a number to a string?
Randy Kramer
rhkramer@fast.net
Sat, 05 May 2001 21:48:48 -0400
Oops, I see the reason for my second problem -- I keep trying to do
"testsh" instead of "./testsh".
Randy
Randy Kramer wrote:
>
> I've written a bash script that almost works. (I want to dress it up a
> little with comments and a command line parameter, but that I can handle.)
>
> #!/bin/bash
> for i in $(seq 1 1 105)
> do
> wget -v -O linuxnote$i.txt http://linuxnote.swiki.net/$i.raw
> done
>
> The script uses wget to get the content from the pages of a wiki (swiki) and
> saves them to separate files that include a number in the name. The files
> are named:
>
> linuxnote1.txt
> linuxnote2.txt
> ...
> linuxnote10.txt
> ...
> linuxnote105.txt
>
> I prefer to name them like this:
>
> linuxnote001.txt
> linuxnote002.txt
> ...
> linuxnote010.txt
> ...
> linuxnote105.txt
>
> So I need to find a way to format the integer i as a three digit number.
>
> I know one ugly way to do it, I can divide the loop into multiple loops and
> concatenate "00" in front of 1 thru 9 and a "0" in front of 10 thru 99, but
> there must be a better way.
>
> I have a second problem. For some reason, I can't invoke the program except
> by using /bin/bash <script_name>. Bash is located in /bin/bash, and I've
> chmod'd the script to 777, and I think I have the shebang line correct, but ?
>
> Thanks,
> Randy Kramer
>
> #!/bin/bash
> for i in $(seq 1 1 105)
> do
> wget -v -O linuxnote$i.txt http://linuxnote.swiki.net/$i.raw
> done
>
> _______________________________________________
> Lvlug mailing list
> Lvlug@thelinuxlink.net
> http://www.thelinuxlink.net/mailman/listinfo/lvlug