shell中将字符中换行符'n'替换为空格

xiaoxiao2021-02-28  34

如下所示,文件hello.txt中有5行数据,要将这5行数据在一行中显示出来,并用空格分隔。

jie$ cat hello.txt 1 2 3 4 5

从下方法均可实现: 方法1.

jie$ echo `cat hello.txt` 1 2 3 4 5

方法2.

jie$ cat hello.txt |sed ':jix;N;s/\n/ /g;b jix' 1 2 3 4 5

方法3.

jie$ cat hello.txt | xargs 1 2 3 4 5
转载请注明原文地址: https://www.6miu.com/read-2250051.html

最新回复(0)