unexpand
的手册页指出:
By default, only leading blanks and tabs are reconverted to maximal strings of tabs.
但是,它似乎肯定也在转换内部空白:
echo " HELLO THERE" | unexpand -t 2 | tr '\t' '_'
产量
_HELLO_ THERE
而不是预期的
_HELLO THERE
如果包含 -a
选项,这就是我期望的输出,但无论有没有该选项,输出都是相同的。
最佳答案
来自the POSIX spec ,强调:
When
-t
is specified, the presence or absence of the-a
option shall be ignored; conversion shall not be limited to the processing of leading<blank>
characters.
expand
的 GNU coreutils 版本(但不是 Apple 使用的 BSD)有一个 --first-only
抵消此行为的选项。
关于macos - 为什么 MacOS 上的 unexpand 可以在没有 "-a"参数的情况下更改内部空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51428546/