stats.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash -
  2. #===============================================================================
  3. #
  4. # FILE: stats.sh
  5. #
  6. # USAGE: ./stats.sh
  7. #
  8. # DESCRIPTION: Prints all needed statistics about the collected *.csv files
  9. #
  10. # OPTIONS: ---
  11. # REQUIREMENTS: wc, cat, uniq, sort
  12. # BUGS: ---
  13. # NOTES: ---
  14. # AUTHOR: Francesco Emanuel Bennici (l0nax), benniciemanuel78@gmail.com
  15. # ORGANIZATION: FABMation GmbH
  16. # CREATED: 01/29/2020 04:17:38 PM
  17. # REVISION: 001
  18. #===============================================================================
  19. set -o nounset # Treat unset variables as an error
  20. echo "[i] Getting stats (this can take a long time!)"
  21. num_files=$(ls -1 *.csv | wc -l)
  22. raw_entries=$(cat *.csv | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')
  23. uniq_entries=$(cat *.csv | sort | uniq | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')
  24. single_entry=$(cat *.csv | sort | uniq -u | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')
  25. size=$(du -ch *.csv | grep total | awk '{ print $1 }')
  26. echo "[i] Number of Files........: ${num_files}"
  27. echo "[i] Total Entries..........: ${raw_entries}"
  28. echo "[i] Total Entries (uniq)...: ${uniq_entries}"
  29. echo "[i] Total Entries (1-time).: ${single_entry}"
  30. echo "[i] Total Data size........: ${size}"