Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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