Skip to content

Instantly share code, notes, and snippets.

@thisdavej
Created March 23, 2018 20:21
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 thisdavej/cd1a68dae52f54241738125906283c81 to your computer and use it in GitHub Desktop.
Save thisdavej/cd1a68dae52f54241738125906283c81 to your computer and use it in GitHub Desktop.
Process a log file and count the number of times different types of buttons were pressed for an IoT project. How would you accomplish?
2018-3-23 9:06:48|circuit board
2018-3-22 18:11:22|dash button
2018-3-22 8:46:54|web
...
# Count number of distinct times each button type pressed
cat button-presses.log | cut -d "|" -f 2 | sort | uniq -c
# Results
# 5 circuit board
# 12 dash button
# 3 web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment