ASPENSMONSTER

February 21, 2009

Nifty Linux Knowledge

Filed under: Uncategorized — Tags: — aspensmonster @ 6:52 am

Flattr this!

I’ve been wanting to learn to write shell scripts for a while now. I always seem to find myself needing or wanting to download multiple files in sequence without having to sit in front of the computer screen for half an hour doing so. I have previous programming experience with Java, but never got around to shell scripting. Now I have. Here’s a simple example of what I’ve done.

#
# My first shell script
#
clear

for (( c=0; c<=100; c++ ))
do echo "LOOPY $c!" >> /home/file.txt
done

This creates a text file with LOOPY 1! and 2 and 3 and so forth. This is particularly handy to do with URLs, since wget can download files in sequence from a text file:

wget -i /home/file.txt

Yeah. It’s handy. I’ll be putting up a post about LaTeX too, which I’ve been working with for the past 24 hours now.

1 Comment »

  1. You can also do the following:

    seq -f ‘LOOPY %04.0f’ 0 100 | wget -i –

    Also, LaTeX is awesome; especially since TeX is a full programming language. The only reason I have a word processor around is to view others documents.

    Comment by Zaki Mughal — January 17, 2010 @ 6:03 pm


RSS feed for comments on this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

19,587 Spambots Blocked by Simple Comments

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>