Hands on Bash >

This repository covers a almost all the basics of bash shell scripting, startig from scratch!
Topics Covered
The complete repository is arranged in following 22 major topics. These topics are given below:
- Hello Bash Scripting
- Redirect to file
-
Comments+
> single line
> multi line
> heredoc -
Conditional Statements
> if-elif-else
> case
> operators -
Loops
> while
> until
> for
> break
> continue -
Script I/P
> $1, $2.., $#, $0, $@
> stdin (standered input) -
Script O/P
> stdout, stderr
> 1> 2>
> shortcuts: >, 1>&2, >& -
Pipes & Export b/w Scripts
> ./export -
String Ops
> {var^}
> {var^l}
> {var^^} -
Numbers and Arithmetic
> (( ))
> bc calculator
> obase / ibase -
declare Command
> restrict var. behaviour
> var. type can’t be restricted
> eg -r (read only) var declearation -
Arrays
> all elements - arr[@]
> index - !arr[@]
> count/len - #arr[@]
> delete - ‘unset arr[index]’
> add - arr[ANY index]=val -
Functions
> ‘local’ var
> passing param - funName arg1 arg2 ..
> returning -
Files and Dir
> mkdir, touch, >, »
> -r, -w, -x, -d, -e, -f -
Sending Emails
> install smtp
> ssmtp.config
> mail structure -
Curl in Script
> -O - keep web name
> -o <file name>, > <file name>
> flag ‘-I’ - header of file -
Professional Menu
> select loop
> waiting (-t <sec>) -
Filesystem Events
> Waiting with ‘inotify’
> using inotifywait
> flag -m -
Intro to grep
> count -c
> case-ignore -i
> line-num -l
> except-match -v -
Intro to awk
> using {print}
> selecting nth ({print $n}) field from line
> picking multiple fields ({print $1,$4,$7})
> searching in line –> /searchKey/ -
Intro to sed
> sed –> screen-editor
> substituting ‘s/-/-/’
> applying globally - ‘g’
> manipulating file (-i) - Debugging Bash Scripts
> while execution cmd (bash -x)
> decleared in script (#!<path-bash> -x)
> Specific part (set -x …<to be debugged>… set +x)
* Codes can be accessed by visiting through the link provided with the topic titles.