Longest line in a file

前端 未结 14 2109
鱼传尺愫
鱼传尺愫 2020-11-27 10:34

I\'m looking for a simple way to find the length of the longest line in a file. Ideally, it would be a simple bash shell command instead of a script.

14条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 11:29

    In perl:

    perl -ne 'print ($l = $_) if (length > length($l));' filename | tail -1
    

    this only prints the line, not its length too.

提交回复
热议问题