Search This Blog

Saturday, November 04, 2006

Loooong bash command

I like bash command. This one is quite long:
for ((i=1;i<36;i++)); do if [ $i -lt 10 ]; then j=0"$i" ; else j="$i" ; fi ; wget --no-check-certificate https://www.linux-magazine.pl/issue/$j/; done
It could be interesting for someone, because in one line there are loop (C-style) and if command. This command download the contents of all Polish LinuxMagazine issues. I have got most of LM issues, but searching some information thru them are quite boring. So I thinking about making some kind of 'searching machine' because one from LM website is weak. My command once more, but this in more readable form:
for ((i=1;i<36;i++)); \
do \
 if [ $i -lt 10 ]; \
    then j=0"$i"; \
    else j="$i" ; \
 fi; \ 
 wget --no-check-certificate https://www.linux-magazine.pl/issue/$j/; \
done

2 comments:

Anonymous said...

I don't know about bash, but with zsh you could use https://www.linux-magazine.pl/issue/{01..35}/

Wawrzek said...

Thanks McKale.
I tried this with Bash, nad it had a problem with 01-09 numbers.
Another resason to move to zsh. When I find the a job I have to do this.