Unit 5: Shell Features - Subjective Questions

CSE105 — Creative Engineering Workshop • Practice Questions with Detailed Answers

20 questions

1

Define pattern matching in the context of the Unix/Linux shell. Explain why wildcards are useful when working with files.

2

Explain the use of the * and ? wildcard characters with suitable examples. How do they differ?

3

Describe the use of character classes ([...]) in shell pattern matching. Illustrate with ranges and negation.

4

Distinguish between wildcards and regular expressions in the Unix shell.

5

What is I/O redirection? Explain the three standard file descriptors used by the shell.

6

Explain output redirection using > and >>. How do they differ?

7

Explain input redirection using < with an example. How is it different from a here-document (<<)?

8

Describe how standard error redirection works. Explain how to redirect both stdout and stderr to the same file.

9

What is a pipe in the shell? Explain its working with a suitable example.

10

Explain pipe chaining (multiple pipes) with an example. How does data flow through the chain?

11

Compare pipes with redirection. When would you use each?

12

What is the tee command? Explain how it is used with pipes.

13

Explain filename expansion (globbing) and the sequence of steps the shell follows to expand wildcards before executing a command.

14

Describe various methods to prevent or disable wildcard expansion in the shell. Why is this sometimes necessary?

15

Write shell commands (with explanation) to accomplish the following tasks using wildcards, redirection, and pipes:

  1. List all .log files.
  2. Count how many .c files exist.
  3. Save a sorted, unique list of users.
  4. Find the 5 largest files in a directory.
16

Explain in detail the working of a pipeline internally, including how the shell uses processes and buffers. Illustrate with a diagram-style explanation.

17

Distinguish between >, >>, 2>, &>, and 2>&1 redirection operators with examples.

18

Explain the brace expansion {...} feature and how it differs from wildcard character classes [...].

19

Discuss common errors and pitfalls when using redirection and pipes, and how to avoid them.

20

Design a single command pipeline that reads a web-server access log, extracts the IP addresses, counts how many times each IP appears, and displays the top 3 most frequent IPs. Explain each stage.