我有一个bash脚本,其中有一个命令
echo -e $(sort $1 | uniq -d)
当从命令行运行此脚本时,所有行都显示在一行中。如何在脚本中添加换行符以分隔所有行?
您可能需要引用回声以保持格式:
echo -e "$(sort $1 | uniq -d)"
看一个例子:
$ myvar="hello
> how
> are
> you"
$ echo $myvar <--- unquoted, loses the format
hello how are you
$ echo "$myvar" <--- quoted, keeps the format
hello
how
are
you
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句