标题:[实践OK]shell 脚本中将输出内容赋值给一个变量时的换行问题,双引号把变量给引起来就有换行了。 出处:向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 时间:Thu, 18 Apr 2019 16:06:22 +0000 作者:jackxiang 地址:http://jackxiang.com/post/10173/ 内容: 如下所示,文件hello.txt中有5行数据,要将这5行数据在一行中显示出来,并用空格分隔。 jie$ cat hello.txt 1 2 3 4 5 从下方法均可实现: 方法1. $ echo `cat hello.txt` 1 2 3 4 5 cat hello.txt | xargs 1 2 3 4 5 $a=$(cat hello.txt) cat "$a" 1 2 3 4 5 原文:https://blog.csdn.net/guoyajie1990/article/details/73692526 Generated by Jackxiang's Bo-blog 2.1.1 Release