Skip to content

Instantly share code, notes, and snippets.

@panchicore
Created September 28, 2017 11:27
Show Gist options
  • Save panchicore/14fc80ecc2c1f7169c57f3b1a7c60135 to your computer and use it in GitHub Desktop.
Save panchicore/14fc80ecc2c1f7169c57f3b1a7c60135 to your computer and use it in GitHub Desktop.
1, Ju3stin T3imb3erlake, Title 545, Price $7.30
2, Tayl4or Sw4ift, Title 723, Price $7.90
3, Mi4ck J3a2gger, Title 610, Price $7.90
4, La3dy Ga243ga, Title 118, Price $7.30
5, Joh234nny C3ash, Title 482, Price $6.50
6, Elvis Presl4ey, Title 335, Price $7.30
7, 444John Lennon4444, Title 271, Price $7.90
8, 444John Lennon4444, Title 271, Price $7.90
9, 444John Lennon4444, Title 271, Price $7.90
10, Ju3stin T3imb3erlake, Title 545, Price $7.30
11, Ju3stin T3imb3erlake, Title 545, Price $7.30
12, Ju3stin T3imb3erlake, Title 545, Price $7.30
13, Ju3stin T3imb3erlake, Title 545, Price $7.30
  • load input.txt (cat)
  • split the csv and take the artist name on a artist list (gawk)
  • clean the artist names, remove numbers (sed)
  • order the artists list to group them (sort)
  • group the unique artists and count the incidences (uniq)
  • order by number of incidences (sort)
  • get top 3 list (head)

cat input.txt | gawk -F", " '{print $2}' | sed "s/[0-9]//g" | sort | uniq -c | sort -r -n | head -3

5 Justin Timberlake
3 John Lennon
1 Taylor Swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment