Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

() vs {} bash

() 
- Placing a list of commands between parentheses causes a subshell environment
to be created, and each of the commands in list to be executed in that subshell.
Since the list is executed in a subshell, variable assignments do not remain 
in effect after the subshell completes.

{}
- Placing a list of commands between curly braces causes the list to be executed
in the current shell context. No subshell is created. The semicolon (or newline)
following list is required.
Comment

$() vs `` bash

$() or `` is called command subsitution

They are the same. Command subsitution allows the output of a command to 
replace the command identifier.
Comment

$() vs () bash

$(cmd) substitutes the result of cmd as a string, whereas (cmd; cmd) run a list of commands in a subprocess.

If you want to put the output of one or more commands into a variable use the $( cmd ) form.

However if you want to run a number of commands and treat them as a single unit use the () form.

The latter is useful when you want to run a set of commands in the background.
Comment

PREVIOUS NEXT
Code Example
Shell :: install playstore anbox 
Shell :: pause bash script 
Shell :: tinymce django install 
Shell :: git submodule remove 
Shell :: change password linux 
Shell :: how to pull remote branch into local branch 
Shell :: show public ip 
Shell :: how to install zsh in fedora 
Shell :: hardhat deploy 
Shell :: add job to crontab 
Shell :: install flutter on linux 
Shell :: how to start docker in ubuntu 
Shell :: crontab command not found 
Shell :: how to install ssh server on ubuntu 16.04 
Shell :: chrome download for linux 
Shell :: how to install spotify in linux 
Shell :: installing sh file linux 
Shell :: search file in ubuntu 
Shell :: list all user ubuntu server 
Shell :: unable to snap ubuntu software 
Shell :: composer change version 
Shell :: laravel installation from github 
Shell :: vuforia git url 
Shell :: rpm install google-chrome-stable in cmd 
Shell :: apt-get uninstall 
Shell :: docker manjaro 
Shell :: bash script to output a specific line of a file 
Shell :: set path environment variable mac permanently 
Shell :: install virtualbox on ubuntu 
Shell :: google-chrome in ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =