wordcount script to get wordcount for specific user

This commit is contained in:
James Tomasino 2020-10-20 12:44:55 +00:00
parent c767371fdb
commit 5d8569c6e8
2 changed files with 7 additions and 1 deletions

View File

@ -11,7 +11,7 @@ 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=$(wc -w /home/"${u}"/ships/**/*.txt | tail -n 1 | awk '{print $1}')
words=$(wordcount "${u}")
printf "%s,%s\\n" "$u" "$words" >> "$temp_scores"
fi
done

6
bin/wordcount Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
if [ -d "/home/${1:-$USER}/ships/" ]; then
wc -w /home/"${1:-$USER}"/ships/**/*.txt | tail -n 1 | awk '{print $1}'
else
printf "0\\n"
fi