假如一个文本文件file是这样的,里面全部是数字
- 740 15972 18307 16248 17862 29009 13603 2239 14893 11235 19566 13175 3291 14677 29570 15409 8693 19836 1979 13319 28403
- 14432 5202 577 30424 25355 30710 31333 7042 23863 9974 7782 7068 28282 24031 24930 24524 4867 27169 6649 16103 13968
- 19824 19394 28645 16627 2036 4570 3696 4016 17889 32100 18448 23091 32678 16104 15678 30620 14669 22721 21716 24644 30504
- 28784 20159 21767 20946 11915 26635 15348 18565 9970 29316 5622 29365 25193 22249 31402 29764 25946 2650 14885 25278 21099
- #!/bin/bash
- MAX=`for i in $(cat file);do echo $i;done|sort -nr|head -1`
- MIN=`for i in $(cat file);do echo $i;done|sort -nr|tail -1`
- echo "the Max number is : $MAX"
- echo "the Min number is : $MIN"