Вы находитесь на странице: 1из 44

1.

Write a shell script to read an existing file extension and a new file extension through command
line. Replace all the occurrence the old file extension with the new extension in the current folder.
Display the name of the file being renamed and display its content.

Op:

2. Write a shell script to simulate a calculator for float numbers (+,-,*,/).

3. Create a file named student with fields (rollno, student name, marks) Fields are separated by
colon(:) .Write a shell script to perform the following options on the file.
1. Print the content of the file
2. Search for name of your friend
3. Delete the given file
4. Create the link for the given by file (by asking the option for hard link/soft link)
If any of above four not selected then print error message

4. Write a shell script to check if entered number is odd or even.

5. Write a shell script to display following menu. Ask user to select the choice and accordingly
complete the task
1. Create a file with the name comp with some contents
2. See the present working directory
3. Check the presence of the file f1 in current dir
4. Store hidden files in f1 and simultaneously display
5. See the contents of comp
6. Exit

6. Write a shell program to accept student details (rollno, mks, grade) from the user at runtime. If the
marks accepted are > 50 then print the result as Pass else print the result as Fail. Count how many of
them have passed and how many have failed.

7. Write a shell script to check if entered year is leap or not.

8. Write a shell script to accept two positive integers through command line. Find and print their
GCD and LCM.
Perform the following error check:
Exactly two numbers should be entered
Number should be positive
Only numeric data should be accepted

Op:

9. Write a shell script to generate Fibonacci series. Read limit from the user.

Op:

10. Write a shell script to accept a string from the user and display the characters at even positions of
the string. Ex: OPERATING SYSTEM -> PRTN YTM

Op:

11. Write a shell script to display no.of days in a the given month.

Op:

12. Write a shell script to create a menu driven program on product (prodno, prodname, price,
expiry_date) to perform following tasks:Adding the new contents to the file at runtime.
Searching for the product with prodno=101 (Assuming this record is entered already)
Display all the products along with their details
Exit

Op:

13. If a number is input thrcd dinough the keyboard, write a shell script to calculate the sum of digits.

14. Write a shell script that asks the user to input a number N and displays the squares of all numbers
from 1 to N as follows: 1 square = . 2 squavi sh15re= . . . N square= .

Op:

15. If cost price and selling price of an item is input through the keyboard, write a shell script to
determine whether the seller has made profit or incurred loss. Also determine how much profit was
made or loss was incurred.

Op:

16. Write a shell script to display vowels and consonants from a given word. Also count the no.of
vowels and consonants and display the value of these counters
.

Op:

17. The distance between two cities (in Km.) is input through the keyboard. Write a shell script to
convert and print this distance in meters, feet, inches and centimeters.

Op:

18. Write a shell script to display the entered number in words. Ex: 213 -> Two One Three

Op:

19. Write a shell script to validate student data and save it in a file.
Note: Data to be saved in file
Roll_No:S_Name:Total_Marks:Grade
Validation:
Roll_No: Should be between 2200 and 2260
S_Name: Should contain only alphabets and space characters
Total_Marks:Should be between 0 and 100
q
Grade: Should be A,B,C,D,E or F :q

OP:

20. Write a shell script to validate date (dd-mm-yy).

[[ $date =~ ^[0-9]{4}(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])$ ]]

Op:

21. Write a menu driven shell script to check entered number is even or odd, find factorial, factors of
a number.
e.g. MENU
1 Even odd check
2 Factorial
3 Factors
0 Exit
User enter the choice as per the choice corresponding output will be displayed. (Factors of the
number 6 are 1, 2, 3 factors of number 10 are 1, 2, 5)

Op:

22. While executing a shell script either the LOGIN NAME or the UID is supplied at the command
prompt. Write a shell script to find out at how many terminals has this user logged in.
{ EXCEPTION }

Op:

23. Write a shell script, which display a list of all files in the current directory those have read, write
and execute permission.

Op:

24. Write a shell script to count ordinary files, special files and directories in the current directory.

Op:

25. Write a shell script, which will receive any number of filenames as arguments. The shell script
should check whether every argument supplied is a file or a directory. If it is a directory it should be
appropriately reported. If it is a filename then name of the file as well as number of lines present in it
should be reported.

Op:

26. Write a shell script to see current date, time, username and current directory (use menu with the
help of case statement)

Op:

27. A shell script receives even number of filenames. Suppose four filenames are supplied then the
first file should get copied into second file, the third file should get copied into fourth file, and so on.
If odd number of filenames are supplied then no copying should take place and an error message
should be displayed.

Op:

28. Write a shell script that will print the entered number in reverse order. Ex 123 -> 321

Op:

29. Write a shell script to list the prime numbers between any range (range will given by the user)

Op:

30. The word unix is present in only some of the files supplied as arguments to the shell script. Your
shell script should search each of these files in turn and stop at the first file that it encounters
containing the word unix. This filename should be displayed on the screen.

Op:

31. Write a shell script to check if the string is palindrome or not.

Op:

32. Write a shell script tol check whether a number is Armstrong number. Ex: 153 =

Op:

+ 5

33. Write a shell script to generate multiplication table of entered number.

Op:

34. Write a shell script to accept a directory hierarchy as command line argument and create the
respective directory structures. Ex: If mca/sem2/os/pracs is entered then create mca, mca/sem2,
mca/sem2/os and mca/sem2/os/pracs.

Op:

35. Write a shell script to read a file name from user and to display the files permissions if it is exists
else display an error message.

Op:

36. Write a shell script to find the total number of logged in users.

Op:

37. Write a shell script to find the total numbers of words, lines and characters in a file entered by the
user.

Op:

38. Write a shell script to check if entered number is a factorial of some interger. Ex: Input -> 120
Output -> 120 is a factorial of 5.

Op:

39. Write a shell script to calculate gross salary of an employee. Take basic salary from the user.
Gross_salary = Basic_salary + 0.20 * Basic_salary - 0.15 * Basic_salary.

Op:

Вам также может понравиться