-1

我是脚本新手。我想将获取 echo 输出的行数合并到一行中:

   echo "$reasult1 \n"
   echo "$reasult2 \n"
   echo "$reasult3 \n"
   echo "$reasult4 \n"
   echo "$reasult5 \n"
   echo "$reasult6 \n"
   echo "$reasult7 \n"
   echo "$reasult8 \n"
   echo "$reasult9 \n"
   echo "$reasult10 \n"

我想要上面的一行。

4

2 回答 2

0

尝试这个:

echo $reasult1 $reasult2 $reasult3 ....
于 2013-10-18T06:53:48.427 回答
0

工作方式echo因外壳而异。你可以printf改用,它更统一一点。

# printf does not print a newline by default. If you really want two newlines per
# echo, as implied by your code, add another \n to the format string.
printf "%s\n" "$result1" "$result2" "$result3"

不管你想要多少变量。第一个参数中的格式会根据需要重复多次,以消耗所有剩余的参数。

于 2013-10-18T12:59:06.223 回答