While reading up on how to set up grub, I came across an article claiming that I need to use one of the following two syntaxes,

echo \(hd0,0\) >> /boot/grub/grub.conf


echo '(hd0,0)' >> /boot/grub/grub.conf

because, at the command line, parentheses are interpreted in a special way. What is special about the parentheses? How are they interpreted?


2 Answers 2


Parentheses denote a subshell in bash. To quote the man bash page:

(list)    list  is  executed  in  a  subshell  environment (see COMMAND
          EXECUTION ENVIRONMENT below).  Variable assignments and builtin 
          commands that affect the shell's environment do not remain in 
          effect after the command completes.  The return status is the
          exit status of list.

where a list is just a normal sequence of commands.

This is actually quite portable and not specific to just bash though. The POSIX Shell Command Language spec has the following description for the (compound-list) syntax:

Execute compound-list in a subshell environment; see Shell Execution Environment. Variable assignments and built-in commands that affect the environment shall not remain in effect after the list finishes.

  • In bash and other shells...?
    – jasonwryan
    Commented Dec 5, 2011 at 0:20
  • 3
    bash is the one i was asking about... Commented Dec 5, 2011 at 0:24
  • 15
    What's the difference between $() and ()? Commented Dec 7, 2015 at 7:47
  • 13
    @CMCDragonkai The $() is command substitution, the () is a subshell. Both of them run commands, the difference is what happens to the output. The names are much easier to search than the symbols. See also unix.stackexchange.com/q/213530/9537
    – jw013
    Commented Dec 7, 2015 at 18:19

A command list embedded between parentheses runs as a subshell.

Variables in a subshell are not visible outside the block of code in the subshell. They are not accessible to the parent process, to the shell that launched the subshell. These are, in effect, local variables.

See Linuxtopia - Chapter 20. Subshells

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .