我有一个很长的字符串可以通过echo
命令打印。通过这样做,我希望它完美缩进。 我想这和它是完全工作正常如何在回声时避免空格被分割成多行
echo "This is a very long string. An"\
"d it is printed in one line"
Output:
This is a very long string. And it is printed in one line
但是,当我尝试正确缩进它作为echo语句也缩进。它增加了额外的空间。
echo "This is a very long string. An"\
"d it is printed in one line"
Output:
This is a very long string. An d it is printed in one line
我找不到任何可以完美实现这一点的工作响应。
谢谢。我正在那样做。只是为了记录,是否有可能使用'echo'? – molecule
@molecule你可以在'$ {lines [@]}“中为'line'做一些事情。做; echo -n“$ line”; done'。但它有点难看,不是吗? – fedorqui
是的,的确很丑。谢谢队友 – molecule