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

前端 未结 2 773
逝去的感伤
逝去的感伤 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:38

    The answer to your question: No, cat command can not "show" spaces as a visible characters. It just does not contain such a feature. Cat only provides -T (show tabs) or -E (show newlines) or -A (show both types).

    I assume palako was meaning to say this, but instead he he jumped straight to providing you a workaround, which is valid. If you are looking to visually count spaces, that's fine. There are many workarounds, and not all will be appropriate for all users.

    If you need something different, I suggest looking into Perl one-liners (because they could adapt easily into existing UNIX scripts), or write something in Python which mimics 'cat' but replaces spaces with another character, much like palako's "tr" example.

提交回复
热议问题