linux - 在linux中用制表符替换空格

如何在给定的文本文件中用 linux 中的制表符替换空格?

最佳答案

使用 unexpand(1) 程序


UNEXPAND(1)                      User Commands                     UNEXPAND(1)

NAME
       unexpand - convert spaces to tabs

SYNOPSIS
       unexpand [OPTION]... [FILE]...

DESCRIPTION
       Convert  blanks in each FILE to tabs, writing to standard output.  With
       no FILE, or when FILE is -, read standard input.

       Mandatory arguments to long options are  mandatory  for  short  options
       too.

       -a, --all
              convert all blanks, instead of just initial blanks

       --first-only
              convert only leading sequences of blanks (overrides -a)

       -t, --tabs=N
              have tabs N characters apart instead of 8 (enables -a)

       -t, --tabs=LIST
              use comma separated LIST of tab positions (enables -a)

       --help display this help and exit

       --version
              output version information and exit
. . .
STANDARDS
       The expand and unexpand utilities conform to IEEE Std 1003.1-2001
       (``POSIX.1'').

https://stackoverflow.com/questions/1424126/

相关文章:

python - 转置一维 NumPy 数组

linux - 如果指向的文件被移动或删除,Linux 上打开的文件句柄会发生什么

python - 创建用 NaN 填充的 numpy 矩阵

python - 如何删除 Python 中的前导空格?

python - 如何在 Python 中列出目录的内容?

windows - 使用什么字符将项目放在字母列表的末尾?

python - 在 Alpine Linux 上安装 Pillow 时没有这样的文件或目录 "li

python - 如何获取项目在列表中的位置?

linux - 工控机性能: Named Pipe vs Socket

linux - 如何从命令行获取 nvidia 驱动程序版本?