OS Lab 5 Journal 11102023 083703am

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Operating System Lab

CSL 320

Lab Journal 5

TALHA ARSHAD
01-134201-090
BS-CS-5B

Department of Computer Science


BAHRIA UNIVERSITY, ISLAMABAD
Operating System
B

TASK B IN LAST JOURNAL


Write shell script code for the following problems except task # 0.

Task 0: What are the Steps to write a Shell Script?


1) Create a file with .sh extention and use any editor to edit it.
#Write command here to create file
2) Set execute permission for your script as follows
#write command here
3) Execute your script as follows
#write command here

Task # 1: Write a script that asks the user to enter three sides of a triangle, calculate its perimeter
and display it in the following format.
The perimeter of triangle with side 1 = ____ side 2 = ____ and side 3 = ____ is: ______.
[Formula: Perimeter of triangle is: side1 + side2 + side3]

Program:

Output:
Task # 2: Write a script that asks the user to enter two integer numbers, stores them in variable
'num1' and 'num2' respectively. The program swaps the values of two variables with each other
using a third variable 'temp' and displays the values of both variables after swapping.

Program:

Output:
Task # 3: Write a script that asks user the radius of a circle, calculate its area and display it in the
following format.
The area of circle with the radius ______ is: _____________.
[Formula: Area of Circle is: πr2]

Program:

Output:

Task # 4: Write a script that takes masses of two objects m1 and m2 and the distance d between
them from user. Now find the gravitational force between the two objects. The formula for the
gravitational force is given.
[Hint: Value of G=6.67×10−11 ]

Program:
Output:
Title: Linux Shell Programming II
Objectives: To study and learn Linux Shell Programming Commands, Relational & logical
operators, Conditional Statements.
Tools Used: Linux Ubuntu Terminal, geddit editor, VS Code

Task # 1: Write a script to find the smallest number from 3 numbers given by user.
Program:
#Write your code here

Output:
#Paste snapshot of your output here
Task # 2: Make a simple calculator which has a nice menu e.g press 1 for addition and so on. It
should have following the functions: Addition, subtraction, division, multiplication and modulus.
Program:
Output:

Task # 3: Through case write a shell script that can differentiate between vowels and consonants.
Program:
#!/bin/bash
Output:

Task # 4: Write a script to find whether a particular triangle is equilateral, isosceles or scalene.
Program:
Output:

Task # 5: Save the path of any file in a variable and write a script to automatically perform all file
tests on it.
Bonus: Take the filename from user, check if it exists then perform file testing on it, otherwise
echo on screen that file doesn’t exist.
Program:
#Write your code here
Output:
#Paste snapshot of your output here
Submission Date

Signature: Ms Umarah Qaseem

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy