0% found this document useful (0 votes)
12 views14 pages

ASSIGNMENT 5 Compressed

Linux basic loops

Uploaded by

sjain87654321
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views14 pages

ASSIGNMENT 5 Compressed

Linux basic loops

Uploaded by

sjain87654321
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

SHAURYA JAIN

0801ME231095
IT SECOND YEAR (B-3)

ASSIGNMENT - 5
Q1. Write a Shell Script Program to Check if a File Exists or not .
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q2 . Create a shell script called hello.sh that:
• Prints "Hello, World!" to the terminal.
• Saves the script, make it executable, and run it.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q3 . Create a script called greet.sh that:
• Stores your name in a variable.
• Prints "Hello, [Your Name]!" using the variable.
and Make the script executable and run it.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q4. Create a script called input.sh that:
• Prompts the user to enter their name.
• Reads the user input and stores it in a variable.
• Prints "Hello, [User Name]!" using the variable.
And Make the script executable and run it
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q5. Using Conditional Statement Create a script called check_number.sh that:
• Prompts the user to enter a number.
• Checks if the number is positive, negative, or zero.
• Prints a message indicating the result.
And Make the script executable and run it.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q6. Create a script called loop.sh that:
• Uses a for loop to print the numbers 1 to 5.
• Uses a while loop to do the same.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q8. Write a Shell Script Program to Check if present month is October or not.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q9 .Write a shell script to count the number of files having read permission in the
current working directory.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q10. Write a shell script to check if the current user is the root user or not ?
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q11 . Write a shell script that takes a directory name as an argument and counts the
number of files and subdirectories inside it. The script should then display the
counts for files and directories separately.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q12.Write a shell script that prompts the user to enter three numbers. The script
should then calculate and display the largest of the three numbers.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q13. Write a shell script that prompts the user to enter a string and then checks
whether the string is a palindrome .
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q14. Write a shell script that prompt the user to enter a number and then checks
whether the number is prime.
SHAURYA JAIN
0801ME231095
IT SECOND YEAR (B-3)
Q15. Write a shell script that reads a list of numbers from the user and then calculates
and displays the sum and average of those numbers.

You might also like