Search code examples
bashcommand

bash for inline command


I have to run commands, in a bash script, and within this bash script I have to run other commands. I am running CentOS.

I found 2 ways to do this on blogs and manuals:

1) using the ticks or accent char

command `sub command`

or

2) using the dollar sign and parentheses

command $(sub command)

What is the difference between the 2 and which one is preferable to use?


Solution

  • There's no difference except in "nestability":

    The $() is nestable:

    $ echo $(echo "hi" $(echo "there"))
    

    while the `` is not.