Experiment -1.
2
Student Name:Sejal Seepal UID: 21CDO1059
Branch: CSE-DevOps Section/Group: 21-BCD-1/A
Semester: 7th Date of Performance: 30/7/24
Subject Name: Development and Testing Automation Subject Code: 21-CSH-448
1. Aim/Overview of the practical:
Write a Shell Scripts for various logical, arithmetic tasks and Branching Statements.
2. Task to be done:
Write a Shell Scripts:
· Shell Scripts for various logical, arithmetic tasks and Branching Statements
· if statement
· if-else statement
· if..elif..else..fi statement (Else If ladder)
· if..then..else..if..then..fi..fi..(Nested if)
· switch statement
3. Steps for experiment/practical:
1. Create the Shell Script File:
nano logical_arithmetic.sh
2. Add the Shebang:
#!/bin/bash
3. Prompt for User Input
4. Perform Arithmetic Operations:
Add, subtract, multiply, and divide the two numbers.
5. Implement Branching Statements:
Use if-else to compare the two numbers and display which one is larger.
6. Display Results:
Print the results of the arithmetic operations and comparisons.
7. Make the Script Executable:
chmod +x logical_arithmetic.sh
8. Run the Script:
./ logical_arithmetic.sh
4. Screenshots:
Creating a Logical_arithmetic file and Opening file in nano editor.
Writing the Script
(Logical and Arithmetic Script) (Branching and Switch case Script)
output
Writing the Script for Conditionals:
1 nano [Link]
2 chmod +x [Link]
3 ./[Link]
output
4. Result/Output/Writing Summary:
The script successfully performed addition, subtraction, multiplication, and division of user-provided numbers,
and used branching statements to compare them, displaying the larger number. It demonstrated effective
handling of arithmetic operations and conditional logic in shell scripting.
Learning outcomes (What I have learnt):
Understanding how to create and execute shell scripts.
Learning to prompt and read user input in shell scripts.
Gaining proficiency in performing basic arithmetic operations in scripts.
Implementing conditional branching using if-else statements..
Enhancing skills in scripting logic for problem-solving in Unix/Linux environments.
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
Sr. No. Parameters Marks Obtained Maximum Marks
1.
2.
3.