disposable-email-domains/alpha_insert.sh

26 lines
498 B
Bash
Raw Normal View History

#!/bin/bash
temp_file="temp.sort"
num_insertions=0
num_duplicates=0
2017-10-10 12:06:28 +08:00
# Append contents of new_file into main_file
# ensuring no duplicates.
while read p; do
if [ $(grep -w $p $2 | wc -l) -eq 0 ]; then
echo $p >> $2
num_insertions=$((num_insertions+1))
else
num_duplicates=$((num_duplicates+1))
fi
done < $1
echo "NUMBER OF INSERTIONS: $num_insertions"
echo "NUMBER OF DUPLICATES: $num_duplicates"
2017-10-10 12:06:28 +08:00
# Sort main_file
sort $2 > $temp_file
cat $temp_file > $2
rm -f $temp_file
#end