[root@master yjt]# cat yjt.sh
#!/bin/bash
awk -v field="$1" '{sum+=$field; n++;}END {if (n > 0) print sum/n;else {print 'error' > "/tmp/.stderr"; exit 1};}' tt
[root@master yjt]# cat tt
1 2 3
1 2 3
4 5 6
[root@master yjt]# cat yjt.sh
#!/bin/bash
awk -v field="$1" '{sum+=$field; n++;}END {if (n > 0) print sum/n;else {print 'error' > "/tmp/.stderr"; exit 1};}' tt
[root@master yjt]# cat tt
1 2 3
1 2 3
4 5 6