1. ## Generate Birthday List

Dear mathematics,
something I thought long time ago came to my mind these days and i tried it out with wg and john but cant get it figured out:

I am trying to create a 8-numbers-dictionary, consisting of 8 numbers
but NOT from 00000000 to 99999999, which of course would be several gigabytes large, but I want to just valid birthday parameters there.

So lets say the first four numbers are 0000 to 3333 and the last four digits should be for EACH 0000 to 3333 general cycle the numbers 1930 to 2015.

Now for the console wizards around - how would that be possible?

best regards
Joerg

2. Sounds like a homework task, n'est-ce pas?

You may try out that:

Code:
```#!/bin/bash

for i in `seq 1 255`; do
for l in `seq 1 12`;do
for k in `seq 1930 2009`; do
echo \$i\$l\$k
done
done
done```

3. thanks, you are close.
But is HAS to be 8 numbers every time. Let me clarify: if its like in cour counter the starters it would be 111930 but that are only 6 numbers. so in case the first number is <10 it has to 01, 02, and NOT 1,2. Correct then would be for my example 01011930.

ya know also how to solve THAT?

regards
Joerg

4. Come on, this isn't rocket science. It's three loops:

01-12
01-31
1930-2015

The biggest decision is to whether to format the output as MMDDYYYY, DDMMYYYY, YYYYMMDD, or YYYYDDMM. All are valid formats depending om locale and usage.

If you want to get tricky and have only valid dates, you can add validity checking for the short length months and leap years. All-in-all his is a trivial exercise that's covered in a programming 101 class. Google for the language of your choice.

5. I am not sure if you understood me right. The LOGIC was NOT the problem but the ZEROS. As the words HAD to be EXACT 8 Digits I had to insert Zeros when necessary.

Solved it like that (maybe stupid but i never ever coded bash...)

regards,
Joerg

///// code

!/bin/bash

for i in `seq 1 31`; do
for l in `seq 1 12`; do
for k in `seq 1930 2009`; do

if [ \$i -lt 10 ] && [ \$l -lt 10 ]; then
echo "0"\$i"0"\$l\$k

else

if [ \$i -lt 10 ]; then
echo "0"\$i\$l\$k

else

if [ \$l -lt 10 ]; then
echo \$i"0"\$l\$k

else

echo \$i\$l\$k

fi
fi
fi

done

done
done

6. Originally Posted by Joerg
I am not sure if you understood me right. The LOGIC was NOT the problem but the ZEROS. As the words HAD to be EXACT 8 Digits I had to insert Zeros when necessary.

Solved it like that (maybe stupid but i never ever coded bash...)

regards,
Joerg
OK, gotcha. Typically, in most languages, you print them as characters or strings, not numbers. Depending on how your favorite language works, you may or may not have to concatenate the leading zero to numbers less than ten, as you did with your code. Also, depending on the language, you may also have to do some sort of type casting or type change.

By the way, the "#" button on the advance posting options allows you to post ASCII code with the formatting intact. Like so:

Code:
```for i in `seq 1 31`; do
for l in `seq 1 12`; do
for k in `seq 1930 2009`; do
if [ \$i -lt 10 ] && [ \$l -lt 10 ]; then
echo "0"\$i"0"\$l\$k
else
if [ \$i -lt 10 ]; then
echo "0"\$i\$l\$k
else
if [ \$l -lt 10 ]; then
echo \$i"0"\$l\$k
else
echo \$i\$l\$k
fi
fi
fi
done
done
done```

7. alright, just added the vice/versa scheme dd/mm/yyyy AND mm/dd/YYYY.
Thats giving exactly the output i was looking for.

regards
Joerg

Code:
```#!/bin/bash

for i in `seq 1 31`; do
for l in `seq 1 12`; do
for k in `seq 1930 2012`; do
if [ \$i -lt 10 ] && [ \$l -lt 10 ]; then
echo "0"\$i"0"\$l\$k
else

if [ \$i -lt 10 ]; then
echo "0"\$i\$l\$k
else

if [ \$l -lt 10 ]; then
echo \$i"0"\$l\$k
else

echo \$i\$l\$k

fi
fi
fi
done
done
done

for i in `seq 1 12`; do
for l in `seq 1 31`; do
for k in `seq 1930 2012`; do
if [ \$i -lt 10 ] && [ \$l -lt 10 ]; then
echo "0"\$i"0"\$l\$k
else

if [ \$i -lt 10 ]; then
echo "0"\$i\$l\$k
else

if [ \$l -lt 10 ]; then
echo \$i"0"\$l\$k
else

echo \$i\$l\$k

fi
fi
fi
done
done
done```

8. Good. Add the Leap Year and short length month validity checks, and you're done.

9. ## ruby power

Code:
```#!/usr/bin/env ruby
require 'date'
startdate = Date.new(y=1930,m=1,d=1)
enddate = Date.new(y=2009,m=3,d=31)
startdate.step(enddate,1) do |d|
puts d.strftime('%m%d%Y')
end```

10. Here is another interesting one:

Imagine you have two lists, one consists of a REALLY large wordlist which may contain (list A):

01031974
06081963
04071940
01011970

and you got another list consisting of stuff like (list B):

aa
ab
ac
ae

NOW what I want is to somehow APPEND all the words in list B to every single word in list A.

So that I can get an even larger list which could look like that here:

01031974aa
01031974ab
01031974ac

and so on.

Any ideas how to solve this?

best regards
Joerg

PS is it possible to read TWO files inside one bash script to read it line by line and then in a while loop read another one line by line. Or may awk can help me?
Sorry i have NO idea of bash coding....maybe my whole question is stinky simple to solve...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•