Hi,
I wanna find the biggest number inside of a file
this is kind of example of file:
9
11
55
then i just wanna print out the biggest number
i had try sed filenale | sort -k1,1n | paste -s -d',' -
but i had no success ...
Hi,
I wanna find the biggest number inside of a file
this is kind of example of file:
9
11
55
then i just wanna print out the biggest number
i had try sed filenale | sort -k1,1n | paste -s -d',' -
but i had no success ...
sort -n filename | tail -1
awk 'BEGIN {big=$1} {if($1>big) big=$1} END {print big}' input_file
you can use this code to find the biggest number. and here $1 means first field i,e here we are having only one column.
also try:
awk '{$1>b?b=$1:0} END{print b}' infile
Works well on positive numbers, but would be in trouble if all numbers were negative.
Try like..
sort -rn test.txt|head -1
---------- Post updated at 04:29 AM ---------- Previous update was at 04:28 AM ----------
Please post your test data ,i will try...
perl -e 'biggest = chop(<>);while(<>) { if(chop() > biggest) biggest = chop();} print biggest;'
Hope I'm right.
#! /bin/bash
x=0
while read n; do [ $n -gt $x ] && x=$n; done < file
echo $x
@radiohead: How does this work?