Multiple strings, Truncate line at 80 characters

前端 未结 5 837
无人共我
无人共我 2021-02-02 05:57

I\'m new to awk and sed, and I\'m looking for a way to truncate a line at 80 characters, but I\'m printing several strings in that line using printf. The last two strings are th

5条回答
  •  既然无缘
    2021-02-02 05:59

    I'm looking for a way to truncate a line at 80 characters ...

    You could pipe the output to cut:

    printf ... | cut -c 1-80
    

    If you wanted to ensure that each line isn't more than 80 characters (or wrap lines to fit in specified width), you could use fold:

    printf ... | fold -w 80
    

提交回复
热议问题