The Bash Shell
Bash – Bourne Again Shell, built upon the Bourne Shell (sh).
sh – Bourne Shell
-> Upon starting the Bash shell. 3 Files are executed:
etc contains all of your settings, all users initiall get the same profile script
2. ~/.bash_profile or .~/.bash_login or .~/.profile
3. ~/.bashrc – start items in the background: applications, programs and startup of system.
* – any string of at least 0 chars
? – any single character
[abc] – similar to javax.regex character classes
[a-z] range [!abc] not
~h5yez – home of h5yez
~+ current working dir – $PWD var.
~- previous working dir – $OLDPWD var.
double quotes: everything between is taken literally except the dollar sign. $-variable \-escape `-tick for cmd subst.
“-end of quoted section
single quote: everything between them is taken literally except:
‘ – apostrophe signals the end of quoted section, W/O – \ (backslash) escape
cmd – exec cmd.
cmd & – exec cmd in bg.
cmd1;cmd2 – exec cmd1 and then cmd2
cmd1|cmd2 – pipe: use output of 1 as input to 2. (good for filtering output)
ie. – ls -lha | grep
ls -lha | wc
cmd1 `cmd2` – use output of cmd2 as an arg to cmd1
i.e. – kill `pid of app`
cmd1&&cmd2 – exec cmd1 then 2 iff 1 is ‘successful’
!cmd – return exit state of 0 when cmd returns non-zero.
(cmd1;cmd2) – group in a subshell -> useful for directing output from both cmd1 and cmd2 to same file.
cmd > file – send stdout of cmd to file (overwrite).
cmd >> file – send stdout of cmd to file ( in append mode ).
cmd < file - take input for cmd from file cmd << text - take all input upto a line identical to text that is reached. -> good for multi-line manual entry.