Linux 命令 将多行文本合并为单行

命令 paste

  • -s:将多行文本合并为单行
  • -d ' ':指定分隔符为一个空格

示例用法

  • 多行文本
line 1
line 2
line 3

运行命令

cat file.txt | paste -s -d ' '

输出结果

line 1 line 2 line 3

猜你喜欢

转载自blog.csdn.net/u010953692/article/details/132314957