Local variables after loop exit

前端 未结 5 690
眼角桃花
眼角桃花 2021-01-03 13:50

I am having some issues with local variables after exiting a loop. The variable max ends up with the value 0, despite the code below:

max=0
cat          


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 14:08

    Here's a one liner in awk.

    $ awk 'length>t{t=length}END{print t}' file
    6
    

提交回复
热议问题