Scripting question

Archaic archaic at comcast.net
Wed Nov 6 11:08:51 PST 2002


I needed to create a file with everyday of the year in mmddyy form.
After searching some bash tutorials on the web I couldn't find an elegant
way to construct the for loop, so I did the brute force method. Any
suggestions? Here's my script (effective, but horrendous). 

#!/bin/bash
y=02

rm -f {newfile,TTB-script}

for m in 01 03 05 07 08 10 12
do
        for d in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 \
                18 19 20 21 22 23 24 25 26 27 28 29 30 31
        do
                echo $m$d$y >>newfile
        done
done

for m in 04 06 09 11
do
        for d in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 \
                18 19 20 21 22 23 24 25 26 27 28 29 30
        do
                echo $m$d$y >>newfile
        done
done

for m in 02
do
        for d in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 \
                18 19 20 21 22 23 24 25 26 27 28
        do
                echo $m$d$y >>newfile
        done
done

sort newfile > TTB-script
#end

-- 
Archaic

-- 
"I hold it, that a little rebellion, now and then, is a good thing, and
as necessary in the political world as storms in the physical."

- Thomas Jefferson, Letter to James Madison, January 30, 1787


-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message



More information about the blfs-support mailing list