use of parenthesis() in shell programming

What's the use of parenthesis () in shell programming ?
I saw this in one of the posts in this forum :

echo $($1)

What confounded me was that it evaluated the inner expression and then the outer one, almost like eval. It seemed like it did this in passes.

It is for using the output of one command in another command, frequently to populate a variable:

output=$( $1 )

The ouput of the command in $1 will be stored in the variable $output.

1 Like

Thanks a lot !