Sunteți pe pagina 1din 3

BHARATI VIDYAPEETHS

INSTITUTE OF COMPUTER APPLICATIONS & MANAGEMENT


(Affiliated to Guru Gobind Singh Indraprastha University, Approved by AICTE, New Delhi)

Lab Assignment
LINUX PROGRAMMING
Concerned Faculty : Dr.Anupam Baliyan

1.
2.
3.
4.

Write a shell script to find the largest among 3 numbers.


Write a shell script to accept a number from user and find its factorial.
Write a script to accept a file name from user and count the number of lines in it.
Accept a string on command line. If it represents a file then show the contents, if it is a
directory show directory listing else display error message
5. Write script, using case statement to perform basic math operation as follows:
i. +
addition
ii. subtraction
iii. X
multiplication
iv. /
division
6. Write a menu driven program to input choice from the user and print the following
patterns as indicated below:
Choice 1
Choice 2
1
12
123
1234
Choice 3

1
12
123
1234
Choice 4

#
5
##
54
## #
543
## #
5432
# #
54321
#
7. Write script to see current date, time, username and current directory.
8. Write script to print given number in reverse order.
9. Write script to print the sum of all digits of a given number.
10. Write a script to perform real number calculation and store result to third variable, lets
say a=5.66
b=4.5
c=a+b
11. Write script to swap two files if they exist, otherwise display an error message.
12. Write a script to accept some numbers at the command prompt and display their sum.

13. Write a script to input a file name and check whether the file exists. If yes, then check
whether it is a regular file, directory, symbolic link, pipe, socket, character device or any
other type of file.
14. Write a script to input two strings and compare them, whether they are equal. Also print
the string which is greater (which comes later in the dictionary).
15. Write a script to print all the files in the current directory and remove those files where
filenames begin with j or m.
16. Write a script to accept a character from a user and check whether it is an alphabet, a
number or a special symbol.
17. Write a script to sort the array using bubble sort.
18. Write a script to enter some elements in the array and print them in reverse order.
19. Display all the command line arguments supplied by user using shift (also called
positional parameters).
20. Write a script to concatenate two arrays.
21. Write a script to enter the names of some countries in the array and replace UK with
United Kingdom.
22. Write a script to enter the names of some students in the array and display the length of
each name in the array.
23. Write a script to swap two arrays and then append an element in both the arrays.
24. Write a script to enter some numbers in the array and print the sum of all the numbers.
25. Write a script to create a file that contains names of all the files present in the current
directory, and then count the number of lines in this file.
26. Define a function that receives two parameters and returns the larger number.
27. Define a function to demonstrate local and global variable visibility.
28. Write a script to accept some strings from command line, assign them in the array and
print the string with the smallest length.
29. Write a script to load an array with some contents, display them, unset the entire array
and load the new contents.
30. Define a recursive function to display a text message n no. of times.
31. Write a script to search an item in the array.
32. Write a script to add two numbers using recursion.
33. Write a script that prints good morning, good afternoon and good evening message
according to the time the script is executed.
34. Write a script to input some elements in the array and find the largest number.
35. Write a script to input names of two files and print the name of the file which is older
than another and also print the permissions assigned to owner, group and others for it.
36. Write a script to generate a the series given below
0 1 1 2 3 5 8 13 21 34
37. Write a script to copy the content of a file into another file and display the content of the
file by using positional parameters.
38. Write a script which check whether a write permission is there for a file ,if yes then
Append some text into it.
39. The marks obtained by a student in 5 different subjects are input through keyboard. The
student gets a division as per the following rule
60 or above it ----------------- First division
Between 50 and 59 -------- Second division
Between 40 and 49 --------- Third division
Less than 40 --------------- Fail

Write a shell script to calculate the division obtained by the student

-----------------------------------------------------------------------------------------------------

S-ar putea să vă placă și