How are parentheses interpreted at the command line?
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
or
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?
bash shell quoting
add a comment |
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
or
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?
bash shell quoting
add a comment |
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
or
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?
bash shell quoting
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
or
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?
bash shell quoting
bash shell quoting
edited Feb 2 '16 at 6:51
G-Man
12.9k93264
12.9k93264
asked Dec 5 '11 at 0:05
Steve Brown
1,2731108
1,2731108
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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
Dec 5 '11 at 0:20
3
bash is the one i was asking about...
– Steve Brown
Dec 5 '11 at 0:24
3
What's the difference between$()and()?
– CMCDragonkai
Dec 7 '15 at 7:47
4
@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
Dec 7 '15 at 18:19
add a comment |
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
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f26063%2fhow-are-parentheses-interpreted-at-the-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
Dec 5 '11 at 0:20
3
bash is the one i was asking about...
– Steve Brown
Dec 5 '11 at 0:24
3
What's the difference between$()and()?
– CMCDragonkai
Dec 7 '15 at 7:47
4
@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
Dec 7 '15 at 18:19
add a comment |
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
Dec 5 '11 at 0:20
3
bash is the one i was asking about...
– Steve Brown
Dec 5 '11 at 0:24
3
What's the difference between$()and()?
– CMCDragonkai
Dec 7 '15 at 7:47
4
@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
Dec 7 '15 at 18:19
add a comment |
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.
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.
edited Dec 9 at 21:42
aldoWan
103
103
answered Dec 5 '11 at 0:09
jw013
35.9k699125
35.9k699125
In bash and other shells...?
– jasonwryan
Dec 5 '11 at 0:20
3
bash is the one i was asking about...
– Steve Brown
Dec 5 '11 at 0:24
3
What's the difference between$()and()?
– CMCDragonkai
Dec 7 '15 at 7:47
4
@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
Dec 7 '15 at 18:19
add a comment |
In bash and other shells...?
– jasonwryan
Dec 5 '11 at 0:20
3
bash is the one i was asking about...
– Steve Brown
Dec 5 '11 at 0:24
3
What's the difference between$()and()?
– CMCDragonkai
Dec 7 '15 at 7:47
4
@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
Dec 7 '15 at 18:19
In bash and other shells...?
– jasonwryan
Dec 5 '11 at 0:20
In bash and other shells...?
– jasonwryan
Dec 5 '11 at 0:20
3
3
bash is the one i was asking about...
– Steve Brown
Dec 5 '11 at 0:24
bash is the one i was asking about...
– Steve Brown
Dec 5 '11 at 0:24
3
3
What's the difference between
$() and ()?– CMCDragonkai
Dec 7 '15 at 7:47
What's the difference between
$() and ()?– CMCDragonkai
Dec 7 '15 at 7:47
4
4
@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
Dec 7 '15 at 18:19
@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
Dec 7 '15 at 18:19
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Dec 5 '11 at 1:04
mark
47627
47627
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f26063%2fhow-are-parentheses-interpreted-at-the-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown