Skip to content

Instantly share code, notes, and snippets.

@fbrundu
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbrundu/9810884 to your computer and use it in GitHub Desktop.
Save fbrundu/9810884 to your computer and use it in GitHub Desktop.
Check if a line is composed by unique words.
# line number after ==
# change \\t with the delimiter you want to use instead of tab for splitting to words
words_count=$(awk 'NR==5{print}' data.csv | tr \\t \\n | wc -l)
unique_words_count=$(awk 'NR==5{print}' data.csv | tr \\t \\n | uniq | wc -l)
if [[ "$words_count" -ne "$unique_words_counts" ]]; then
echo "Not unique"
else
echo "Unique"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment