Echo sequence of numbers with '0' padding for length of 3 chars in CLI
I'm trying to run this command directly via CLI instead of via a shell script.
This is what I have: Code:
$ wget http://www.example.org/module_{1..190}.so That would generate something like: Code:
http://www.example.org/module_1.so But, the problem is, files are named like this: Code:
module_001.so How would I do that? Thanks. |
Google foound a lot of stuff on zero-padding.
e.g. try "seq -w" as in: Code:
for num in $(seq -w 1 10);do |
so why can't you do like this?
Code:
echo {000..190} |
I know this works:
Code:
printf "%03d\n" {1..190} Code:
printf "http://www.example.org/module_%03d.so\n" {1..190} |
I probably should have mentioned that I've also forgotten how to quote the command so that it's not interpreted literally in the one liner.
I did try out seq (but without the -w switch) but how do I quote it into my example? I also like the clean printf solution but I really don't remember how to quote it in. This obviously won't work: Code:
wget printf "http://www.doublefine.com/themes/site_themes/default/images/comics/sc/sc_%03d.jpg" {1..190} Unfortunately, I need you to spoon feed me and tell me exactly how I can use it. I really should re-learn my shell commands. |
well, what I would do is:
Code:
printf "http://www.doublefine.com/themes/site_themes/default/images/comics/sc/sc_%03d.jpg\n" {1..190} > get Code:
printf "http://www.doublefine.com/themes/site_themes/default/images/comics/sc/sc_%03d.jpg\n" {1..190} | while read line; do wget "$line"; done |
I prefer the second solution. Thanks a lot :)
Isn't it possible to do something similar to: Code:
wget http://example.org/foo{1..5}.bar |
curl is better than wget for this because it has a built in ability to create sequences.
From the curl man page: Code:
You can specify multiple URLs or parts of URLs by writing part sets |
Quote:
Code:
curl -o sc_#1.jpg http://www.doublefine.com/themes/site_themes/default/images/comics/sc/sc_[001-190].jpg |
if you use the (IMHO) superior korn shell you can use typeset
observe: Code:
$ typeset -Z3 a |
All times are GMT -5. The time now is 08:04 PM. |