Skip to content

Instantly share code, notes, and snippets.

@cuevasclemente
Created November 10, 2015 22:15
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 cuevasclemente/18ce7e103ce5788576ab to your computer and use it in GitHub Desktop.
Save cuevasclemente/18ce7e103ce5788576ab to your computer and use it in GitHub Desktop.
Sum of the matching part of the last line of a set of files
# First, get the last line of each file (each log file)
# Then, pull the floating point number at the end of the line
# Then, collect the sum of `1/floating_point_number`. At the end, print
# s
tail -n 1 *.log | grep -e "[0-9]\.[0-9]*$" -o | awk '{s+=1/$1} END {print s}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment