Skip to content

Instantly share code, notes, and snippets.

@alperyilmaz
Created November 17, 2016 13:42
Show Gist options
  • Save alperyilmaz/bbee15da74c0119785df3b315623a4c4 to your computer and use it in GitHub Desktop.
Save alperyilmaz/bbee15da74c0119785df3b315623a4c4 to your computer and use it in GitHub Desktop.
frequency of year and genre combination
$ rev movies | cut -f1-2 | rev | sort | uniq -c | sort -nr | head
85 2002 Drama
84 2000 Drama
80 1998 Drama
80 1996 Drama
79 1999 Drama
78 2001 Drama
74 1995 Drama
68 1997 Drama
62 1994 Drama
54 1996 Comedy
# the fourth column has items like "Comedy|Drama" so the results above is showing that there were 85 movies in 2002 which were ONLY in drama genre.
# the bottom of the list illustrates that fourth column is not sorted according single genre
$ rev movies | cut -f1-2 | rev | sort | uniq -c | sort -nr | tail
1 1920 Comedy
1 1919 Drama|Romance
1 1919 Comedy|Drama
1 1919 Adventure|Drama
1 1919 Action|Adventure|Drama
1 1917 Drama|Romance
1 1917 Comedy
1 1916 Drama
1 1916 Action|Adventure|Sci-Fi
1 1915 Drama|War
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment