How to truncate STDIN line length?

前端 未结 9 1768
醉酒成梦
醉酒成梦 2021-01-05 07:15

I\'ve been parsing through some log files and I\'ve found that some of the lines are too long to display on one line so Terminal.app kindly wraps them onto the next line. Ho

9条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-05 07:40

    The usual way to do this would be

    perl -wlne'print substr($_,0,80)'
    

    Golfed (for 5.10):

    perl -nE'say/(.{0,80})/'
    

    (Don't think of it as programming, think of it as using a command line tool with a huge number of options.) (Yes, the python reference is intentional.)

提交回复
热议问题