|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
It's not a matter of there being any particular advantage or disadvantage to using one or another. These are different ways of executing commands and doing job control. Each has it's use.
The single ampersand executes the command in the background (in other words, it doesn't block the shell while the process is running: it runs the command, "detaches" it from the shell and returns to the shell right away). A pair of grave accents is used for command substitution. It's normally used within another command such as echo Hello, `id -un`! (the id(1) command within the echo(1) command).In your case, since there's nothing else, it simply runs the command. The double ampersand is a logical operator (conditional AND). The second command after the && runs only if the first command returns successfully. In your case you didn't specify that second command so the shell opened a subshell so that you can type and run it. You could've just run firefox && echo hello world! You're not using these features in a very "creative" way (no offense intended), that's why they feel similar. Their usefulness becomes more apparent when used within elaborate shell scripts.
__________________
May the source be with you! |
|
||||
To comment on the other (first) example in the OP
$ $( command ) is just another syntax for $ ` command ` Both do the same thing: command is run and its standard output is substituted in place of $( command ), in the cmd line where it occurred. Normally the command would be chosen to output some useful text that you want to insert in the original cmd line; firefox probably doesn't do this. For more detail you should study the man page for your shell in the areas where these are described. There are all kinds of weird/cool things that can be done. |
Tags |
openbsd, subshell |
|
|