📘 PAPER 5 – OPERATING SYSTEM (UNIT 5 – SHELL PROGRAMMING & FILTER COMMANDS) university of allahabad
🔴 UNIT 5 – SHELL PROGRAMMING & FILTER COMMANDS
🟢 1. Introduction to Shell
✅ What is a Shell?
A Shell is a command-line interpreter that:
-
Accepts user commands
-
Executes them
-
Acts as an interface between user and OS
🔹 Types of Shells in Linux
| Shell | Description |
|---|---|
| sh | Bourne shell |
| bash | Bourne Again Shell (most used) |
| csh | C shell |
| ksh | Korn shell |
| zsh | Advanced shell |
👉 Bash is most commonly used.
🟢 2. Shell Programming
✅ Definition
Shell programming is writing a script to automate tasks using shell commands.
🔹 Advantages
✔ Saves time
✔ Automates tasks
✔ Easy to write
✔ Used in system administration
🟢 3. Structure of Shell Script
Explanation:
-
#!/bin/bash→ Shebang line -
echo→ Print output
🔹 Running a Shell Script
🟢 4. Variables in Shell
User Defined Variable
System Variables
🟢 5. Read Command
🟢 6. Conditional Statements
🔹 if Statement
🔹 if-else
🔹 Case Statement
🟢 7. Looping Statements
🔹 for Loop
🔹 while Loop
🟢 8. Command Line Arguments
🟢 9. Filter Commands
Filter commands process text input and give output.
🔹 1. grep
Search text in file
🔹 2. sed
Stream editor (search & replace)
🔹 3. awk
Used for report generation
🔹 4. cut
Extract columns
🔹 5. sort
Sort data
🔹 6. uniq
Remove duplicate lines
🟢 10. Pipes
Used to connect commands.
🟢 11. Shell Keywords
| Keyword | Use |
|---|---|
| if | Condition |
| then | Execution |
| fi | End if |
| for | Loop |
| do | Loop start |
| done | Loop end |
🟢 12. Shell Script Example
Program: Check Even or Odd
📌 IMPORTANT EXAM QUESTIONS (UNIT 5)
✔ Explain shell scripting
✔ Write shell program for even/odd
✔ Explain grep, sed, awk
✔ Explain pipes & filters
✔ Write notes on shell variables
✔ Explain case statement
Comments
Post a Comment