how to display spaces and tabs using unix and the “cat” command

前端 未结 2 747
逝去的感伤
逝去的感伤 2021-02-20 16:14

I\'m trying to figure out how to display the contents of a file through unix where the spaces and tabs are marked somehow. I know how to display the files with tabs (aka c

2条回答
  •  离开以前
    2021-02-20 16:40

    There's a standard unix tool for character substitution. In this example, I'm replacing spaces for * and tabs for &:

    $ cat tmp
    space tab   space   tab end
    tab space   tab space end
    $ cat tmp | tr " " "*" | tr "\t" "&" 
    space*tab&space&tab&end
    tab&space&tab*space*end
    

提交回复
热议问题