Display name
Display name

Reputation: 780

What is happening in this command substitution?

I have written the following command substitution and executed in in a bash shell:

$(echo echo 1; echo 2; echo 3) #output: 1 2 3

Why is the double echo required in the first expression, while only single echos are required in the second and third?

Upvotes: 0

Views: 15

Answers (1)

PaulProgrammer
PaulProgrammer

Reputation: 17620

It has to do with what you've actually asked the shell to do. That is as follows:

"Echo the result of echo 1; echo 2; echo 3"

Upvotes: 1

Related Questions