Quiz Space

System Commands OPPE 2: September 2023, Set 1 (September 2023 term)

Question 1

+15 marksProgramming

In a markdown file, the level of heading is decided by the number of # at the beginning of the line. For example, # at the beginning of the line indicates a level 1 heading, ## indicates a level 2 heading and so on. There is a space between # and heading text. The sample input shown below conveys the simplicity of the test cases.

Write a SED script 'script.sed'

  • To reduce the level of heading by 1, for example # to ## and ## to ###
  • Add "# Text editors in Linux" as the first line

Sample Input

# Line Editors
## Ed
---
# Modal Editors
## Vi
## Vim
## Neovim
---
# Non-modal Editors
## Nano
## Emacs

Sample Output

# Text editors in Linux
## Line Editors
### Ed
---
## Modal Editors
### Vi
### Vim
### Neovim
---
## Non-modal Editors
### Nano
### Emacs

Question 2

+15 marksProgramming

A student named Pankaj found the output of the diff command confusing. He found two lines that looked the same but were marked as different. He presumed that it could be due to the presence of tab spaces present in the file. He wants to see the line end and tab characters. He decided to replace the tab spaces with "^I" and mark the end of the line with "$" in the files.

Write a sed script 'script.sed' to visualize the line end and tab characters by replacing them with $ and ^I, respectively.

Example:

$ cat file_a
abcd
efgh

$ cat file_b
efgh
ijkl

$ diff -u file_a file_b
--- file_a 2023-11-27 14:29:47.230882094 +0530
+++ file_b 2023-11-27 14:29:53.640882534 +0530
@@ -1,3 +1,3 @@
 abcd
-efgh
+efgh
 ijkl

$ diff -u file_a file_b | ./script.sed
--- file_a^I2023-11-27 14:29:47.230882094 +0530$
+++ file_b^I2023-11-27 14:29:53.640882534 +0530$
@@ -1,3 +1,3 @@$
 abcd$
-efgh$
+efgh $
 ijkl$

Question 3

+15 marksProgramming

Programmers are used to tag comments in the code with TODO, REVIEW, NOTE, HACK, FIXME, and DEPRECATED keywords.

Write an AWK script 'script.awk' to find all the occurrences in files and print only the filename and line number in the format <filename>:<line number>.

3 more questions in this paper

Sign in with Google — it is free — to see every question with its answer and explanation, practise it in learning mode, or take it as a timed mock test.

More on the System Commands OPPE 2 Sept 2023 Set 1 paper

The IIT Madras BS System Commands (System Commands) OPPE 2 paper sat on Sept 2023, in the September 2023 term (T3 2023), set 1: 6 questions for 90 marks in 180 minutes. The first 3 questions are below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeatureSystem Commands OPPE 2 Sept 2023 Set 1 at a glance
TermSeptember 2023 term (T3 2023)
SubjectSystem Commands
Course codeBSSE2001
Questions6
Marks90
Duration180 min
Programming6
Official paperOPPE 2, Sep 2023 Set 1
Negative markingNo negative marking.
Updated

Other sets that day

More System Commands