Pregunta

I have a bash script where there is a command

echo -e $(sort $1 | uniq -d)

When this script is run from the command line, all the rows come out in one line. How can I get an newline character into this script to get all the lines separated?

¿Fue útil?

Solución

You may need to quote the echo to keep the format:

echo -e "$(sort $1 | uniq -d)"

See an example:

$ 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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top