#!/bin/sh

# Checks for argument. If there are less than 2, show error message.
if [ $# -lt 2 ]
then
    echo "Usage: $0 arg1=filename arg2=number_of_files"
    exit
fi

# Create (for example a1 to a5) .txt file with a random number in each.
i=1
while [ $i -le $2 ]
do
    echo $RANDOM > $1$i.txt
    let i=$i+1
done

# Takes numbers in each .txt file and list them in aa.txt.
cat $1*.txt > $1$1.txt