macos - 为什么 MacOS 上的 unexpand 可以在没有 "-a"参数的情况下更改内部空间?

标签 macos unix expand

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/

相关文章:

R:如何将包含 "list"的行扩展到多行...每个列表成员一个?

ios - 使用 Xcode5.1 错误为 iOS 编译 libogg

linux - 使用 WinSCP 在不同帐户之间切换用户

linux - "opt"是什么意思(如在 "opt"目录中)?是缩写吗?

iOS 如何只展开一个单元格

html - 触发折叠/展开内容的 Javascript

ruby-on-rails - 无法在 Mac OS X 10.8 上使用 Homebrew FreeTds 捆绑安装 tiny_tds

macos - NSDrawer 添加到应用程序窗口时导致崩溃

c - OpenMPI bind() 因错误地址已在使用中而失败 (48) Mac OS X

linux - 将子目录中的文件复制到仅存在 1 个文件扩展名的临时文件夹