提取出每行的最大值
Posted byglen | inshell | 发布日期:2006-11-08 20:42:47 | 总浏览:919 | [评论本文]
例如有如下文件:
3 5 7
4 6 2
4 4 0
那么最后提取出的就是:
7
6
4
===========
-bash-3.00# vi a.sh
#!/bin/bash
while read line;do
max=
set -- $line
while [[ $# != 0 ]];do
[[ -gt $max ]] && max=
shift
done
echo $max
done<a
==========
-bash-3.00# sh a.sh
7
6
4
-bash-3.00# cat a
3 5 7
4 6 2
4 4 0
-bash-3.00#