cosmic/bin/scores

20 lines
382 B
Bash
Executable File

#!/bin/bash
finish () {
if [ -f "$temp_scores" ]; then
rm "$temp_scores"
fi
}
trap finish EXIT
temp_scores=$(mktemp -t "$(basename "$0").scores.XXXXXXX") || exit 1
for u in $(voyagers); do
if ls /home/"${u}"/ships/**/*.txt &> /dev/null; then
words=$(wordcount "${u}")
printf "%s,%s\\n" "$u" "$words" >> "$temp_scores"
fi
done
sort -rnt"," -k2 "$temp_scores"