Unit2 - Subjective Questions

CSE325 • Practice Questions with Detailed Answers

1

Describe the steps required to create and execute a Shell Script. How are permissions changed to make a script executable?

2

Differentiate between Environment Variables and User-Defined Variables in Linux Shell scripting with examples.

3

Explain how to perform arithmetic operations in shell scripting using expr. What are the limitations of expr?

4

How can floating-point arithmetic be performed in shell scripting? Explain the usage of the bc command with an example.

5

Explain the concept of Input/Output Redirection in Linux. Describe the operators >, >>, and <.

6

What are Pipes in shell scripting? How are they different from I/O redirection? Provide an example combining both.

7

Write a shell script to determine if a number entered by the user is Positive, Negative, or Zero using if-elif-else constructs.

8

Explain the syntax of the case statement in shell scripting. Create a simple menu-driven calculator script (Add, Sub, Mul, Div).

9

Compare the while loop and the until loop in shell scripting with appropriate syntax and examples.

10

Explain the for loop construct in shell scripting. Provide examples for iterating over a list of items and a C-style for loop.

11

What are Indexed Arrays in shell scripting? How do you declare, assign values, and access elements in an indexed array?

12

Describe Associative Arrays in shell scripting. How do they differ from indexed arrays? Provide an example.

13

How are User-Defined Functions created in shell scripts? Explain how parameters are passed to functions with an example.

14

Explain the significance of the following positional parameters and special variables: #, ?, and $$.

15

Write a shell script to calculate the factorial of a given number using a while loop.

16

Write a shell script to generate the Fibonacci series up to terms.

17

Explain the File Test Operators in shell scripting used to check file attributes (e.g., -f, -d, -r, -w, -x, -s).

18

Write a shell script that accepts a filename as a command-line argument and checks if it exists. If it exists, display its permissions; otherwise, create it.

19

What are the loop control statements break and continue? Explain their behavior with an example.

20

How can you debug a shell script? Explain the execution modes -v and -x.