Professional Documents
Culture Documents
Worksheet 7
Worksheet 7
AIM:
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
SOFTWARE REQUIREMENTS
is
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:
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)