- Primative and complex data type operations using bash.
- Bash function library tags (trees) are a work-in-progress.
-
- Prerequisites
- Primative Data Types
- Simple Data Type Structures
- Advanced Data Type Structures
- Complex Data Type Structures
-
Syntax + Tools
-
Simple Calculations:
bash $ SUM=$(( VAR2+VAR1 ))
bash $ DIFFERENCE=$(( VAR2-VAR1 ))
bash $ PRODUCT=$(( VAR1*VAR2 ))
bash $ QUOTIENT=$(( VAR1/VAR2 ))
-
Errors:
- Class: errorsSyntax
- Class: errorsType
- Class: errorsValue
- Class: errorsPattern
- Class: errorsHandler
- Class: errorsLogger
- Tests propagate towards --debug by raising errors that get handled.
- Result Codes = 0,1,2:
bash LAST_RESULT_CODE=$?
- Simplest AND:
bash $ $CMD1 && $CMD2
- Simplest OR:
bash $ $CMD1 || $CMD2
- https://unix.stackexchange.com/questions/128005/xor-of-a-shell-variable-and-a-binary-file
- Bash XOR ~ |||:
bash $ $CMD1 && echo 1 ||| $CMD2 && echo 2
- Parentheses Make Complex Logic Explicit:
bash $ ( $CMD1a && CMD1b ) || ($CMD2a && $CMD2b)
- input+output tests: tryCatchFnally() { ;}
-
Logical Operators + Shell Expansion
-
basics:
- case
- if
- test
-
bash file test operators: [ -x $FILE_NAME ]
- a
- b
- c
- d
- e
- f
- g
- h
- k
- p
- r
- s
- t
- u
- w
- x
- G
$ [ -L fileA ]
:$ [ -N fileA ]
:$ [ -O fileA ]
:$ [ -S fileA ]
:$ fileA -ef fileB
: True when fileA and fileB refer to same device and inode numbers.$ fileA -nt fileB
: True when fileA newer than fileB.$ fileA -ot fileB
: True when fileA older than fileB.
-
Loops
- for
- while
- prompts: $ #
- subcommands: $ CMD SUBCMD
- options: $ CMD --help
- arguments: $ CMD --file
- parameters: $ CMD --file=ascii.txt
- flags: $ CMD
- defaults:
- statement syntax
- cmd < input > output
- try-catch
- while...
- man xargs
-
Dev Environment:
- Locally in Free Visual Source Code Editor:
- Locally on the command line
- Remote Open Source Web Playground Environment
- Remote Gitpod
-
Software Dependencies: bash3 seq bc editor
-
Knowledge: ??
-
Text: strings
- Sample Text Data Operations: concatenate <|> split
-
Numbers: integers + bits + bytes
- Sample Numeric Data Operations: maths
-
Temporal: dates + times
- Sample Temporal Data Operations: date_diff()
-
Custom data type primatives: (x,y)
- Sample Custom Data Operation: graphPoint(x,y)
-
ascii symbols: $ # <|>
-
2d locus: x,y
-
lists: x,y,z
-
seqs:
$ NUMS_TO_100=$( seq 100 )
-
stacks:
-
arrays: matrices from homogenous and heterogenous arrays via conjugations
- MATRIX_VAR_NAMES_ARRAY=( ?? )
- MATRIX_PAGE_CONFIGS=( aspectRatio humanLanguage )
- MATRIX_FIGURE_CONFIGS=( type title [ bitmap | vector ] )
- MATRIX_CONFIGS=( quadrant axis1 axis2 legend )
- MATRIX_AXIS_CONFIGS=( name units xyzn )
- MATRIX_AXIS_LABEL_CONFIGS=( font color location )
- MATRIX_AXIS_??=( )
-
dicts
-
enums with default values
- declare -a HUMAN_LANGUAGES_ARRAY=( en es fr ja he ?? ); HUMAN_LANG_DEFAULT='en'
- Bools default to False until True.
- No errors in bash ( RC = 0 ) are successes.
- Errors in bash ( RC > 0 ) are failures. They can be handled so as not to abort.
- Test runs default to Failed until Passed. Options include: ( fail pass incomplete )
-
sets with null default
- declare -a STATES_ZIPS_NESTED_ARRAY=( '' STATES ZIPS ); DEFAULT=''
-
baselines
- high water marks
-
https://stackoverflow.com/questions/10730066/bash-memory-usage?rq=3
-
itertoolz: generators parsers iterators
-
repositories
-
targets:
-
spectra
-
timelines:
-
cycles:
-
graphs:
-
matrices:
-
trees: [un]flatten()
-
chains: chars >-- strings >-- lines >-- files >-- directories >-- volumes
-
translations:
-
taxonomies:
-
diagrams:
-
colors
-
notes
-
beats
- ⊂ is a subset of
- ⊆ is a proper subset of
- ⊃ is a superset of
- reverse: <|>
- one-to-many: --<
- many-to-one: >--
- class-types: --E
- types-class: ∃--
- Clusters >--< Services
- Deployments
- Comparing Linux shells.
- Compare bash to PowerShell
- Comparing bash3x vs bash 4x.
- Test driven demos of bash builtins
- Other linux tools like git.
- How to compare and test programming languages.
- Linux Cluster and System Administration
- Linux Cluster and System Engineering
-
PDF: An Introduction to Programming With Bash, by David Both
-
Bash Binary Info from Terminal...
$ bash --version # Print Bash Version Info
$ man bash | col -b > bash3-manual.txt # Output Man Bash Page To Readable Text File
- Bash Functions Support Code Reuse...
$ f_getBinaryVersion() { ${1} --version || ${1} version ; }
$ f_manTxt() { man ${1} | col -b > linux-${1}-manual.txt ; }