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 :: curl head request 
Shell :: ssh-keygen -t rsa 
Shell :: linux move all files up a directory 
Shell :: git show list of stashes 
Shell :: git force merge branch 
Shell :: add line at beginning of file unix 
Shell :: cat eof 
Shell :: warning unprotected private key file ec2 
Shell :: install react-native-community hooks 
Shell :: docker stop running container 
Shell :: get current time curl 
Shell :: git get develop to feature branche 
Shell :: lib cairo win64 installation 
Shell :: remove letter in string bash 
Shell :: git clone ssh key 
Shell :: how to install dependencies from package.json 
Shell :: installing mongodb on m1 mac 
Shell :: start new git repo from project 
Shell :: how to run docker not with sudo 
Shell :: install amplify cli on mac 
Shell :: applescript open new terminal tab 
Shell :: reset repo 
Shell :: install bootstrap in angular 10 
Shell :: firewall-cmd add service 
Shell :: nodemon use 
Shell :: HOW TO SEARCH FOR A FILE IN COMMAND PROMPT 
Shell :: open podfile in xcode from terminal 
Shell :: copy folder from ssh to local 
Shell :: how to remove sensitive data from github history 
Shell :: delete tag beautifulsoup 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =