Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

57 rader
1.3 KiB

SAMESTR="ThisIsTheSameString" #Same String for uniq
readonly SAMESTR
##
# Get random integar between 1 and 100
##
function getRandomName(){
rnd=`expr $RANDOM % 64 + 1`
return $rnd
}
##
# Get random string, first parametar is length
##
function getRandomString(){
openssl rand -base64 $1
}
function generate(){
size=500
i=0
while(( $i < $size ))
do
getRandomName
length=$?
#echo "START"
if [[ $length -ge 1 && $length -le 25 ]]
then
echo $SAMESTR
else
echo `getRandomString $length`
fi
let "i++"
done
}
function sortByASCII(){
generate | sort | uniq -u
}
function sortByNumeric(){
generate | sort --numeric-sort | uniq -u
}
echo "Overwrite lines:" > resultASCII #this line should not appear in output file
sortByASCII > resultASCII
echo "Append lines:" >> resultASCII #this line should appear in output file
sortByASCII >> resultASCII
echo "Overwrite lines:" > resultNumeric #this line should not appear in output file
sortByNumeric > resultNumeric
echo "Append lines:" >> resultNumeric #this line should appear in output file
sortByNumeric >> resultNumeric
echo "Number of same string in file:"
generate > randomLines
grep --only-matching $SAMESTR < randomLines | wc --lines