Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

PRACTICAL-7

NAME: Tavleen Kaur UID: 18BCS1177

CLASS: 2/B O.S LAB

AIM:

 Write a Shell Script to print the following pyramid using do-while


loop:
#
###
#####
#######
#########

m
er as
###########

co
#############

eH w
 Write a Shell script to demonstrate if, elif, else and fi statements.

o.
Show output screenshot
rs e
ou urc
 Write a script that accepts an integer from the user and
determines whether the integer is a zero, negative, odd or an even
number. Show output screenshot.
o

 Write a Shell Script which shows that loop terminates as soon


aC s
vi y re

as ‘a’ becomes 5. Show output screenshot.


 Write a shell script to check is a number is present in an array
using for loop. Show output screenshot.
ed d
ar stu

SOFTWARE REQUIREMENTS
is

Linux/Ubuntu windows/ Chrome browser, online compiler:


Th

HARDWARE REQUIREMENTS:
sh

Minimum 384MB RAM, 100 GB hard Disk, processor with 2.1 MHz

This study source was downloaded by 100000837820664 from CourseHero.com on 12-01-2021 02:41:32 GMT -06:00

https://www.coursehero.com/file/88374101/worksheet-7docx/
DESCRIPTION:

The syntax for while loop is:

while condition

do

statements

done

The “fi” keyword used after every if else block represents that the if else statement
has ended. Like other programming languages we have same function of “break”
and “continue” in shell script as well.

m
er as
CODE 1: PRINT THE GIVEN PATTERN

co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

OUTPUT 1:

This study source was downloaded by 100000837820664 from CourseHero.com on 12-01-2021 02:41:32 GMT -06:00

https://www.coursehero.com/file/88374101/worksheet-7docx/
m
CODE 2: USE OF IF ELIF AND FI BLOCK

er as
co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

OUTPUT 2:

This study source was downloaded by 100000837820664 from CourseHero.com on 12-01-2021 02:41:32 GMT -06:00

https://www.coursehero.com/file/88374101/worksheet-7docx/
CODE 3: INTEGER IS ZERO, ODD,EVEN, POSITIVE OR NEGATIVE

m
er as
co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

OUTPUT 3:

This study source was downloaded by 100000837820664 from CourseHero.com on 12-01-2021 02:41:32 GMT -06:00

https://www.coursehero.com/file/88374101/worksheet-7docx/
m
er as
co
eH w
o.
CODE 4: USE OF “BREAK” KEYWORD
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

OUTPUT 4:

This study source was downloaded by 100000837820664 from CourseHero.com on 12-01-2021 02:41:32 GMT -06:00

https://www.coursehero.com/file/88374101/worksheet-7docx/
m
er as
CODE 5: SEARCHING IN AN ARRAY

co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

OUTPUT 5:

This study source was downloaded by 100000837820664 from CourseHero.com on 12-01-2021 02:41:32 GMT -06:00

https://www.coursehero.com/file/88374101/worksheet-7docx/
m
er as
co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

This study source was downloaded by 100000837820664 from CourseHero.com on 12-01-2021 02:41:32 GMT -06:00

https://www.coursehero.com/file/88374101/worksheet-7docx/
Powered by TCPDF (www.tcpdf.org)

You might also like