If you are used to run Linux commands, most probably it is on Bash Shell. Bash shell scripting is a scripting language that is used to run multiple commands and process inputs/outputs through variables, regular expressions, controls, conditions, loops and functions. Linux operating system has lots of system programs written in bash.
What I am going to learn throughout this course?
In this course, you will learn following important concepts and hands on stuff:
Run different commands through bash script
Use loops, controls, variables, and functions with different commands
Parse files using bash script
Process system resources using bash script
Set bash scripts to run as a daemon and trigger when some event occurs
Please check the curriculum for more information..
Who Should Join this program & What Are the Pre-Requirements:
Software Testers (QA), Business Analysts, Programmers, Project Leads, Managers and anyone who is working in linux environment and wants to automate commands using bash bash scripting.
Needs prior knowledge about Linux commands. You may look “Linux Operating System and Commands” from our portal.
Outline
Introduction to Shell Scripting
Linux Operating System and Kernel
Linux Shells and Bash Shell Scripting
Writing and running Shell scripts
Echo Command
Adding Single & Multi Line comments
Shell Variables
Quotes - Single, double, escape character
Read Statement
Arithmetic Operations
Customizing Bash Shell Environment
Exit Status
Commands, Logical Operators and Conditional Expression
Test command for condition
logical && and || linked with exit status
Logical not !
Conditional expressions
String comparison
File attributes
Regular Expression and Expansions
Regular Expression (RegEx) is a key for bash
RegEx samples
Expansions and Parameters
Expansion Order
Examples:
Wrong and Write way of expansions
Parameter Expansion
Using tr, awk, sed and shopt command for substitution
Exit and exit status
Decision Making
If condition with test
if...else...fi
Nested ifs
Multilevel if-then-else
Switch case
Loops and Controls
For loop with item list, expression,
While loop
While loop with decisions and expressions
Until loop
Until loop vs while loop
break, continue and exit
Using Selection for Menu work
Select Script to change file permission
Command Arguments
Shell I/O Redirection
input(0)
output(1)
error(2)
Here document
Discard outputs
Functions
Using blocks
Defining functions
Calling functions
Passing arguments
Global and Local variables
Tips of shell scripting for Linux admins
Drawing special pattern
Creating colorful output
Encrypt a file directory
Check server utilization
Check disc space and send email alert
Tips and tricks to improve performance of shell scripting
Better file handling
Use only necessary commands inside a loop
Use commands with possible options
Use internal commands than external if possible
Avoid useless use on commands
Minimize using ls for file listing
Use sed/awk properly
Bash Shell Scripts for Functional Testing
On Demand:
Bash Shell Scripts for Functional Testing
These basic steps and recommendations can be applied to many client/server applications that run in Linux.
Document the prerequisites and main sequence for running scripts
Divide actions into logical groups
Develop an execution sequence based on a common usage scenario
Provide comments and instructions in each shell script
Make an initial backup to create a baseline
Check for input parameters and environment variables
Try to provide "usage" feedback
Try to provide a "silent" running mode
Provide one function to terminate the script when there are errors
When possible, provide functions that do a single task well
Capture the output of each script, while watching the output being produced
Inside each script, capture the return code of each line command
Keep a count of the failed transactions
Highlight the error messages for easy identification in the output file
When possible, generate files "on the fly"
Provide feedback on the progress of the execution of the script
Provide a summary of the execution of the script
Try to provide an output file that is easy to interpret
When possible, provide cleanup scripts and a way to return to the baseline
Assessment:
Scenario 1: Write a bash script to print name of each user from /etc/passwd.
Scenario 2: Write a bash script that counts vowels, blank space, “an”, “a”, characters, numbers of lien and symbol for a given file.
Scenario 3: Write a bash script that reads a file and prints even and odd numbered lines to separate files.
Scenario 4: Write a script to monitor Linux Server disk space using while loop and email alert when used space .+ 90%.
Scenario 5: Write a script that Parses two directories and deletes similar files from first directory.
Scenario 6: Write a script to sum an input number’s digit