linux 中同时输出一组数值的最大值和最小值

 

001、

[root@PC1 test2]# ls
a.txt
[root@PC1 test2]# cat a.txt                                       ## 测试数据
8
3
9
1
7
3
[root@PC1 test2]# sort -rn a.txt | awk 'NR == 1; END {print $0}'   
9
1
[root@PC1 test2]# sort -rn a.txt | sed -n '1p; $p'
9
1
[root@PC1 test2]# sort -n a.txt | sed -n '1p; $p'
1
9

 

posted @ 2023-02-09 15:13  小鲨鱼2018  阅读(36)  评论(0编辑  收藏  举报