1.1. Shell Scripting
Shell script is a reusable series of commands put in an executable text file within extension of ‘.sh’. Any text editor can be used for writing scripts.
Scripts start with ‘#!’ followed by the path ‘bin/bash’ to the shell executing file and after them the commands from the script would be written. shell scripts are interpreted, not compiled. Comments are added to a script for your own future referencing and also to make that understandable for other users. It is better to have too many explanations on comments than not enough.
Debugging a script file can be done on using shell options. Shell options can be used for partial debugging or for analyzing the whole script commands and orders. Inserting echo command is a good strategic for common troubleshooting technique. Debugging of script also can be done by online shell script checker such as https://www.shellcheck.net/ which clearly and obviously shows the location of problems and giving similar information to the errors of scripts. And when you found the errors you can solve that if you wouldn’t you can ask it from https://stackoverflow.com/ websites to solve that.
1.1.1. Key advantage of writing shell script?
• Shell script can take input from user, file and then output them on screen as you need.
• Useful to create your own commands.
• Save lots of time.
• automate tasks.
• System Administration part can be also automated.
1.1.2. Shell types
like people know different languages and dialogues, UNIX system will usually offer a variety of shell types:
• Sh : The original shell which still used on UNIX systems and in other UNIX-related environments. it is available on every Linux system for compatibility with UNIX programs.
• Bash: this is the standard GNU shell, understandable and flexible. Most advisable for new starter users while being at the same time a powerful tool for the advanced and professional users. Linux,’bash’ is the standard shell for common users. This shell is known superset of the Bourne shell, a set of add-ons and plug-ins. it means that the Bourne Again shell is compatible with the Bourne shell: commands that work in ‘sh’ also work in ‘bash’. The reverse is not always the same case.
• Csh: syntax of this shell analogize to the C programming language Also known as C shell.
• Tcsh : is a super set of the common C shell. also call it the Turbo C shell or TENEX C shell.
• Ksh : people sometimes appreciate this with a UNIX background. Which is a superset of the Bourne shell; with standard configuration a nightmare for beginning users. This also known as Korn shell.