How to truncate long matching lines returned by grep or ack

前端 未结 8 1753
攒了一身酷
攒了一身酷 2020-12-13 05:38

I want to run ack or grep on HTML files that often have very long lines. I don\'t want to see very long lines that wrap repeatedly. But I do want to see just that portion of

8条回答
  •  无人及你
    2020-12-13 05:57

    You could use less as a pager for ack and chop long lines: ack --pager="less -S" This retains the long line but leaves it on one line instead of wrapping. To see more of the line, scroll left/right in less with the arrow keys.

    I have the following alias setup for ack to do this:

    alias ick='ack -i --pager="less -R -S"' 
    

提交回复
热议问题