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 :: rmdir recursive 
Shell :: scp from server to my computer 
Shell :: sort linux 
Shell :: bash if with function call 
Shell :: find resolution of image terminal linux 
Shell :: docker stop swarm 
Shell :: jenkins download 
Shell :: make new branch in git 
Shell :: zip exclude directory 
Shell :: linux kill ssh connection 
Shell :: grep usage 
Shell :: pwd in command prompt 
Shell :: mount is fstab 
Shell :: save terminal output to file with script 
Shell :: install bottom navigation in native 
Shell :: how to revert commit in git 
Shell :: git modify last commit but leave the commit message 
Shell :: powershell command line variables 
Shell :: git clone without project folder 
Shell :: linux install software 
Shell :: how to download dash through pip in conda prompt 
Shell :: Command of Git Fetch 
Shell :: merge another branch into current 
Shell :: copy branch to master 
Shell :: diff between two files 
Shell :: curl x imap 
Shell :: install figlet package and run a simple command 
Shell :: how to get data from pc to cluster 
Shell :: cope file linux 
Shell :: How to ssh to multiple servers and run commands 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =