Skip to content

Instantly share code, notes, and snippets.

@vaughany
Created July 27, 2020 08:03
Show Gist options
  • Save vaughany/bd3f46fc23342d28e78de3b68270fe8d to your computer and use it in GitHub Desktop.
Save vaughany/bd3f46fc23342d28e78de3b68270fe8d to your computer and use it in GitHub Desktop.
Little bash script to create a CSV file containing many thousands of fake (but valid) URLs.
#!/bin/bash
# Each 'run' generates 10 unique URLs, so if RUNS=10 you'll get 100 lines out.
# Requires `gpw` to be installed, as a source for nice, random strings.
FILE=large-test.csv
RUNS=10000
if test -f "$FILE"; then
truncate -s 0 $FILE
else
touch $FILE
fi
for (( i=1; i <= $RUNS; i++)); do
string=$(gpw 1 25)
echo "http://$string.co.uk" >> $FILE
echo "http://$string.net" >> $FILE
echo "http://$string.org" >> $FILE
echo "http://$string.org.uk" >> $FILE
echo "http://$string.eu" >> $FILE
echo "http://$string.ie" >> $FILE
echo "http://$string.irish" >> $FILE
echo "http://$string.cymru" >> $FILE
echo "http://$string.wales" >> $FILE
echo "http://$string.scot" >> $FILE
if [[ $(( $i % 100 )) -eq "0" ]]; then
echo "Done $(wc -l $FILE | cut -d " " -f 1) lines."
fi
done
echo
echo "$(wc -l $FILE | cut -d " " -f 1) lines."
echo
ls -gh $FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment