Create a file with email addresses / usernames

Quickly create a list of email addresses / usernames in the format usernameprefixNumber@domain.name

 

#!/bin/bash
userprefix=$1;
numberofusers=$2;
domain=$3;
filetosave=$4
counter=1;

if [ $# -ne 4 ]; then
echo Insufficient arguments:
echo "Usage: $0 userprefix numberofusers domainname filetosave"
echo " - enter user prefix, e.g. demo"
echo " - enter number of users,e.g. 100"
echo " - enter domain/hostname, e.g. some-hostname.domain.com"
echo " - file to save the result in"
exit 1
fi

touch $4 ;


while [[ $counter -le $numberofusers ]];
do echo Creating User $counter;
echo "$userprefix$counter@$domain" >> $4;
let "counter += 1";
done
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s