Find the minimum number in a file using a Bash script

I have a program that prints a number (the run time specifically) and I have written a Bash script that runs the program with another variable every time. How I can find the minimum of these numbers?

Upvotes: 1

Views: 2647

Answers (1)

Barmar
Barmar

Reputation: 781721

You can use sort to get the lowest number in a file:

sort -n filename | head -1

sort sorts it numerically, and then head gets the first line of `sort's output.

Upvotes: 1

Related Questions