Linux 7th Assign
Linux 7th Assign
0801ME231095
IT SECOND YEAR (B-3)
ASSIGNMENT - 7
Q1. Create a shell script using while loop that counts down from 10 to 1, displaying
each number on a new line, and then prints "your name!”.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q2. Write a Shell Script to Reverse a Number
Create a shell script that takes a number as input from the user and reverses it using a
while loop.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q3. Write a Shell Script to Find the Length of a String
Create a shell script that prompts the user to enter a string of your name and then
calculates and displays its length using a while loop.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q4. Write a shell script that prints the first 5 even numbers (starting from 2) using a
while loop.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q5. Write a Shell Script to Print Fibonacci Series
Create a shell script that prints the Fibonacci series up to a specified number of terms
provided by the user using while loop.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q6.Write a Shell Script to Print Even Numbers
Create a shell script that does the following:
1. Print your name and roll no.
2. Initializes a counter variable to 0.
3. Uses a while loop to print all even numbers from 0 to 20.
4. Increment the counter by 2 in each iteration of the loop.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q7. Write a Shell Script to Calculate Factorial
Create a shell script that calculates the factorial of a number entered by the user. Use
a while loop to perform the calculation.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q8. Create a Shell Script to Find the Largest Number
Write a shell script that prompts the user to enter positive numbers and keeps track of
the largest number entered and display the largest number.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q9. Create a Shell Script to Calculate the Average of Positive Numbers
Write a shell script that prompts the user to enter numbers and calculates their
average. display the average and your name with rollno.
ME231095
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q10. Create a Shell Script to Reverse a String
Write a shell script that prompts the user to enter a string and reverses it using a while
loop.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q11. Create a Shell Script to Find the Sum of Digits in a Number
Write a shell script that prompts the user to enter a positive integer and calculates the
sum of its digits using a while loop.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q12. Create a Shell Script to Generate a Sequence of Even Numbers
Write a shell script that prompts the user to enter a positive integer n and generates a
sequence of even numbers from 2 to n using a while loop.