Skip to content

Instantly share code, notes, and snippets.

@n1lux
Last active February 12, 2021 14:03
Show Gist options
  • Save n1lux/b5d8bea0009e2dec4aa54ca1ca82e832 to your computer and use it in GitHub Desktop.
Save n1lux/b5d8bea0009e2dec4aa54ca1ca82e832 to your computer and use it in GitHub Desktop.
Bash-tips
#Count word occurrences in file
grep -wo '[[:alnum:]]\+' filename | sort | uniq -cd
# Iter over sum of a word occurence, get first column (awk print$1) and store sum in variable $sum
for i in $(grep -wo '[[:alnum:]]\+' alunos_atualizaram.txt | sort | uniq -cd| awk '{print $1}'); do sim=`expr $sum + $i`; done
echo $sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment