awk: find minimum and maximum in column

前端 未结 4 416
慢半拍i
慢半拍i 2020-12-09 17:00

I\'m using awk to deal with a simple .dat file, which contains several lines of data and each line has 4 columns separated by a single space. I want to fin

4条回答
  •  眼角桃花
    2020-12-09 17:42

    late but a shorter command and with more precision without initial assumption:

      awk '(NR==1){Min=$1;Max=$1};(NR>=2){if(Min>$1) Min=$1;if(Max<$1) Max=$1} END {printf "The Min is %d ,Max is %d",Min,Max}' FileName.dat
    

提交回复
热议问题