Shell
Shell, also known as Bourne Shell Programming written by Steve Bourne, appeared in the 7th Edition Bell Labs Research of Unix. Its purpose is to automate computing procedures such as a list of commands, pretty much like a cooking recipe to a chef.
Overview of the Guide
For this section of guides, you will learn SHELL as a programming language (yes it is possible) but comes as a price: self-discipline. Otherwise, abusing it might ends up another stage of Javascript horror. There are 2 main variants I'm currently supporting:
- The POSIX Compliant Bourne Shell (also known as
sh
) - The Bourne-Again Shell (known as
BASH
)
Why bash? more of the supports across Linux OSes and commonly used in desktop and server.
Shell Usefulness
Folks learn shell script mainly for:
- fun and easy to use
- integrate various complexity of programs together easily
- automation
Of course, once in a while, you'll meet some crazy folks like me who turn it into a day-to-day programming language.
Supported Types
There are various Shell variants in the market. In this guide, we only focus on 2 types:
- POSIX compliant type - the one that works everywhere
- BASH type - the one upgraded for using shell as a programming languages
What to do Next
If you're ready, use the navigation bar to find the guide of the one type you're looking for. I had arranged the topic in a sequential manner for easy references. You can also read through the materials I did for producing this guide!
References
- http://wiki.bash-hackers.org/scripting/debuggingtips
- https://www.thegeekstuff.com/2008/09/bash-shell-take-control-of-ps1-ps2-ps3-ps4-and-prompt_command/
- https://stackoverflow.com/questions/13710806/how-to-replace-placeholder-character-or-word-in-variable-with-value-from-another
- https://stackoverflow.com/questions/11650840/linux-remove-redundant-paths-from-path-variable
- https://www.amazon.com/gp/search?index=books&linkCode=qs&keywords=9781118024485
- https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
- http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
- http://mywiki.wooledge.org/BashFAQ/031
- http://mywiki.wooledge.org/
- https://serverfault.com/questions/52034/what-is-the-difference-between-double-and-single-square-brackets-in-bash
- http://mywiki.wooledge.org/BashPitfalls
- http://mywiki.wooledge.org/BashGuide/TestsAndConditionals
- https://stackoverflow.com/questions/44688460/bash-script-pattern-matching
- https://www.tldp.org/LDP/abs/html/subshells.html
- https://mywiki.wooledge.org/BashProgramming
- http://wiki.bash-hackers.org/syntax/pe
- https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html
- http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
- https://stackoverflow.com/questions/6499486/how-to-mark-an-array-in-posix-sh
- https://stackoverflow.com/questions/34434157/posix-sh-syntax-for-for-loops-sc2039
- http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm
- https://stackoverflow.com/questions/35693980/test-for-regex-in-string-with-a-posix-shell
- https://stackoverflow.com/questions/21115121/how-to-check-pattern-match-by-using-bin-sh-not-by-bin-bash
- https://unix.stackexchange.com/questions/409065/how-does-curly-brace-expansion-work-in-the-shell
- http://www.linfo.org/wildcard.html
- https://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns-with-pattern-having-a-pipe-character
- https://askubuntu.com/questions/621981/for-loop-syntax-in-shell-script
- https://stackoverflow.com/questions/34256437/shell-bash-how-to-prompt-a-user-to-select-from-a-dynamically-populated-list
- https://aty.sdsu.edu/bibliog/latex/debian/bash.html
- https://stackoverflow.com/questions/40681745/capitalize-each-input-string-in-shell-script
- https://unix.stackexchange.com/questions/312280/split-string-by-delimiter-and-get-n-th-element
- https://stackoverflow.com/questions/51052475/how-to-iterate-over-the-characters-of-a-string-in-a-posix-shell-script
- https://stackoverflow.com/questions/369758/how-to-trim-whitespace-from-a-bash-variable
- https://www.unix.com/shell-programming-and-scripting/17374-strip-leading-trailing-spaces-only-shell-variable-embedded-spaces.html
- https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable
- https://pubs.opengroup.org/onlinepubs/009695399/utilities/read.html
- https://stackoverflow.com/questions/5014823/how-to-profile-a-bash-shell-script-slow-startup
- https://askubuntu.com/questions/915132/measure-performance-of-a-fast-bash-script
- https://www.linuxquestions.org/questions/linux-newbie-8/time-difference-calculation-4175459414/
- https://askubuntu.com/questions/274349/getting-cpu-usage-realtime
- https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash