Linux shell script Practice Questions



1) Use a for loop to show users existing in the system. The output should be in a tabular format.

2) Use a table to display the network interfaces in the system.

3) Display output in the format

********Hello***********
-------------------------------------
| Sr. No. | Test | Test1 | Yes  |
-------------------------------------
|   10      | ABC| DEF | Yes  |
|   20      | DEF | FKG|  Yes |
------------------------------------

4) Write a script to print table of 2 in below format

2*1 = 2
2*2 = 4
......
2*10 = 20

5) Display the following menu to user
  a) Add
  b) Subtract
  c) Multiply
  d) Divide
Then ask for his choice of operation(a-d). Then get two numbers from user and perform the operation.


6) Take a number from user and print a triangle of stars from that number. For e.g. if user enters 3

*
**
***

7) Write a script that takes two arguments search and replace and the third argument is a filename. The script should search for that search term in the file and replace it with the replace term .

8) Take three numbers from user and find which one is the biggest of all.

9) Take a filename and check if it exists

10) Take a filename and check if write permission is granted

11) Take 7 numbers and make a sum of these numbers.

12) Write a shell script that adds a extension .text to all files in a specified directory

13) Write a shell script to backup any specified folder as a tar file.

Comments