when I call env
to see the environment variables it shows nicely with new lines:
$ env
SHELL=/bin/sh
EDITOR=vi
PWD=/home/user
...
but when I want to store this to a file the new lines get discarded:
$ echo $(env) > root.env
SHELL=/bin/sh EDITOR=vi PWD=/home/user ...
What goes wrong? how can I store the env
output with each item on a line?
env > root.env
. No need to use a subshell. – Stewart Jun 07 '22 at 10:57echo $(...)
, theecho
and the command substitution just undo each other. – ilkkachu Jun 07 '22 at 11:47echo $(stuff)
? – Kamil Maciorowski Jun 08 '22 at 20:00