Awk solution:
Code:awk 'max=="" || $1 > max {max=$1} END{ print max}' digits.txt
I have file in my unix system. The file contains numbers in each line. I want to find the maximum value from these numbers using awk command. Sample data is shown below:
How to do that?Code:> cat digits.txt 10 20 5 60 100 7
Awk solution:
Code:awk 'max=="" || $1 > max {max=$1} END{ print max}' digits.txt
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks