Unit3 - Subjective Questions

CSC104 • Practice Questions with Detailed Answers

1

Explain the basic structure of a Bash script and the significance of the Shebang line.

2

Define variables in Bash. How are they declared, and how can user input be stored in a variable?

3

What are Positional Parameters (Arguments) in Bash scripting? List the specific variables used to access them.

4

Explain how to handle Arithmetic Operations in Bash using let, expr, and double parentheses.

5

Describe the syntax for declaring and accessing Arrays in Bash.

6

What is String Slicing (Substring Extraction) in Bash? Provide examples.

7

Distinguish between File Test Operators and String Test Operators in conditional expressions.

8

Explain the concept of 'Exit Status' in Bash. How is it checked?

9

Describe the syntax and usage of the if-elif-else statement in Bash.

10

Explain the case statement in Bash. When is it preferred over if-else?

11

Differentiate between while and until loops in Bash scripting.

12

Explain the two common syntax styles of the for loop in Bash: List-based and C-style.

13

What are break and continue statements? How do they affect loop execution?

14

How are Functions defined in Bash? How do you pass arguments to a function and access them?

15

Discuss the various Debugging options available in Bash scripting.

16

What are Aliases in Bash? How can you make an alias persistent across system reboots?

17

Explain Command Chaining operators (&&, ||, ;) with examples.

18

How can you create a Custom Command using a Bash script and make it executable from anywhere in the system?

19

Write a Bash script that takes a filename as an argument, checks if it exists, determines if it is a file or directory, and prints the result. If it doesn't exist, create it as a file.

20

Create a Menu-Driven Bash script using select or case and while loops that performs basic arithmetic operations (Add, Subtract, Multiply, Quit).