Lab - 03 - Manual
Lab - 03 - Manual
Lab 03
Bash Scripting (Part - 1)
Prepared By: Ridwan Mahbub, Lecturer, CSE, BUBT
Description:
Welcome to Lab-3! In this lab, we will continue our journey through Bash scripting
and build upon the concepts covered in "Introduction to Bash Scripting - Part 1"
lab. In this session, we will explore variables, operators, and conditional statements
in Bash, allowing us to create more dynamic and powerful scripts.
Lab Objectives:
1. Familiarize yourself with new Linux commands beyond those covered in
Lab - 2.
2. Learn about variables and their usage in Bash scripts.
3. Understand different types of operators and how they work in Bash.
4. Master the concept of conditional statements for decision-making in scripts.
Lab Content:
1. Variables in Bash
a. Introduction to variables and their purpose in scripting.
b. Declaring and assigning values to variables.
c. Variable naming conventions and best practices.
d. Displaying variable values using echo and command substitution.
2. Operators in Bash
a. Arithmetic operators: +, -, *, /, %, ** (exponentiation).
b. Relational operators: -eq, -ne, -lt, -le, -gt, -ge.
c. Understanding operator precedence.
3. Array Usage in Bash
a. Introduction to arrays and their purpose in scripting.
b. Declaring and initializing arrays.
c. Accessing array elements using indexes.
Conclusion:
In this lab, you have expanded your knowledge of Bash scripting by
exploring variables, operators, conditional statements, and array usage.
These powerful concepts will enable you to create more sophisticated and
efficient scripts to tackle a wide range of tasks in Linux and other Unix-like
environments. Continue to practice and explore Bash scripting to further
enhance your skills as a Linux enthusiast or administrator.