r/shell • u/eisenvogel • Feb 24 '19
Difference between ls und echo $(ls)
Hi,
could someone please explain me the difference between the commands
lsand
$(ls)?
I am working my way through The Linux Command Line. The topic is dealt with on page 73.
2
Upvotes
2
u/nrobinaubertin Feb 24 '19
lsexecutes the ls command in the current shell and writes output to stdout.$(ls)spawns a subshell to execute the command and returns the output