-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBASH-CHEAT-SHEET-IMP.txt
More file actions
46 lines (28 loc) · 1.79 KB
/
BASH-CHEAT-SHEET-IMP.txt
File metadata and controls
46 lines (28 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
https://devhints.io/bash
https://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html -> IMP
https://yeonghoey.com/unix-like/expansions/
https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzahz/rzahzparamexp.htm
http://ngelinux.com/brief-explanation-string-and-array-slicing-in-bash-shell-linux/ --> BASH string slicinig
https://zwischenzugs.com/2018/10/12/eleven-bash-tips-you-might-want-to-know/
https://linuxconfig.org/bash-scripting-tutorial
https://www.shellscript.sh/tips/pattern-substitution/
https://spin.atomicobject.com/2014/02/16/bash-string-maniuplation/
https://tiswww.case.edu/php/chet/bash/bashref.html
https://developpaper.com/examples-of-the-meaning-and-use-of-set-and-shopt-command-options-in-the-shell/
http://matt.might.net/articles/bash-by-example/
http://redsymbol.net/articles/unofficial-bash-strict-mode/
Expression Result Comments
${path##/*/} long.file.name ## takes out longest matched substring from the front
${path#/*/} cam/book/long.file.name # takes out shortest matched substring from the front
$path /home/cam/book/long.file.name
${path%.*} /home/cam/book/long.file % takes out shortest matched substring from the rear
${path%%.*} /home/cam/book/long %% takes out longest matched substring from the rear
var=/Users/karlin/git/langton_loops/index.html.erb
echo ${var} # => /Users/karlin/git/langton_loops/index.html.erb
echo ${var#*.} # => html.erb
echo ${var##*.} # => erb
echo ${var%/*.*} # => /Users/karlin/git/langton_loops
file=${var##/*/} # => index.html.erb
echo ${file%.*} # => index.html
echo ${file%%.*} # => index