Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The output of

# ls


# echo $(ls)

are the same. What exactly does the $ sign and the parenthesis mean?

Also, what is going on a technical level that causes the output of these two commands to be the same?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

This is command substitution for bash.

Command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed as follows:

 $(command) or






And a good example similar to your question:


share|improve this answer

() and $() are used to run commands in a subshell

See http://tldp.org/LDP/abs/html/subshells.html for details

share|improve this answer

Using $ in front of a variable name invokes the value assigned to the variable. Echo without the $ will just print the name of the variable to the screen (or standard out).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.