Day 4
Session Summary β Shell Scripting Basics Timeline
00:00 β 00:45 | Session Start & Introduction to Shell Scripting
-
Trainer checks studentsβ knowledge of scripting
-
Introduction to shell scripting basics
-
Reference to previous cron job automation task
00:45 β 02:40 | Why Shell Scripting is Used
-
Real-world example: creating hundreds of users from a CSV file
-
Manual vs automated user creation
-
Interactive vs non-interactive user creation:
-
adduser -
useraddwith flags
-
02:40 β 05:30 | What is a Shell
-
Different types of shells:
-
Bash
-
Zsh
-
-
Shell as an interpreter
-
Creating first script file
05:30 β 06:50 | First Script: Hello World
-
Creating script file
-
Permission issue explanation
-
Adding executable permission:
-
chmod +x
-
-
Running the script
06:50 β 10:20 | Variables in Shell Script
-
Creating variables:
-
name -
age
-
-
Memory concept of variables
-
Dynamic value replacement
-
Example output with different values
10:20 β 11:40 | Taking User Input
-
Using
read -pto accept input -
Prompting user for name
-
Displaying dynamic output
Input/Output & Redirection
11:40 β 13:50 | Output Redirection Basics
-
Creating empty file
-
Writing to file using:
-
>(overwrite)
-
13:50 β 15:30 | Append Redirection
-
Using:
-
>>(append)
-
-
Difference between overwrite and append
-
Practical examples
15:30 β 17:20 | Input Redirection & Error Redirection
-
Using
<for input -
Standard output vs standard error
-
Redirecting errors:
-
2>
-
-
Combining stdout and stderr:
-
2>&1
-
Pipes and Command Chaining
17:20 β 20:10 | Pipe Concept (|)
-
Using
ps aux | grep mysql -
Filtering command output
-
How pipe passes output to another command
20:10 β 22:50 | Practical Pipe Example
-
Counting files using:
-
ls -
grep -
wc -l
-
-
Real-world log file counting scenario
Conditional Statements
22:50 β 26:10 | If Condition Basics
-
Writing a simple
ifcondition -
Checking numeric values
-
True vs false condition behavior
26:10 β 30:20 | If Condition with File Check
-
Checking if file exists:
-
-fflag
-
-
Printing message if file exists
-
Real-world use case:
-
Validating CSV file before automation
-
Loops in Shell Scripting
30:20 β 33:40 | Introduction to Loops
-
Need for loops in automation
-
Example: processing CSV file rows
-
Basic loop concept
33:40 β 36:20 | Looping Through Numbers and Files
-
Iterating through values
-
Reading file line by line
-
Processing each line
36:20 β 39:20 | Practical Automation Example
-
Reading user data from file
-
Dynamically creating users
-
Using variables inside loops
Loop Control Statements
39:20 β 42:00 | Break and Continue Concepts
-
Using
breakto exit loop -
Using
continueto skip iteration -
Example:
-
Skipping specific values
-
Real-world scenario: skip certain users
-
Best Practices & Advanced Concepts
42:00 β 45:30 | Learning Approach & Documentation
-
Importance of fundamentals over memorization
-
Using documentation and search
-
Problem-solving mindset in scripting
45:30 β 48:20 | Practical Use Case with User Prompts
-
Example:
-
Database backup script
-
Prompt before pushing backup to cloud storage
-
48:20 β 49:40 | DRY Principle & Functions
-
Concept: Do Not Repeat Yourself (DRY)
-
Using functions in scripts
-
Plan to cover advanced scripting next session
Session Wrap-Up
49:40 β End | Summary & Closing
-
Recap of shell scripting basics
-
Practice instructions
-
Q&A
-
Session end