Quiz Space

System Commands OPPE 2: May 2023, Set 2 (May 2023 term)

Question 1

+15 marksProgramming

In a proofreading task, it is usually required that each of the sentences in a manuscript should be numbered along with paragraph number. Write a bash script to print each sentence of a paragraph saved in sample.txt to a new line and add sentence number and paragraph number above each of the line.

Hint: One of the possible approaches is to use while loop along with IFS. This approach will need to remove leading and trailing spaces from line and add a fullstop at the end of each line.

Sample case

The plains are as flat as the proverbial pancake--a dead monotony of cultivated alluvium, square mile upon square mile of wheat, rice, vetch, sugar-cane, and other crops, amidst which mango groves, bamboo clumps, palms, and hamlets are scattered promiscuously. In some places the hills rise sheer from this, in others they are separated from the alluvial plains by belts of country known as the Tarai and Bhabar. The Tarai is low-lying, marshy land covered with tall, feathery grass, beautifully monotonous. This is succeeded by a stretch of gently-rising ground, 10 or 20 miles in breadth, known as the Bhabar--a strip of forest composed mainly of tall evergreen sal trees (Shorea robusta). These trees grow so close together that the forest is difficult to penetrate, especially after the rains, when the undergrowth is dense and rank. Very beautiful is the Bhabar, and very stimulating to the imagination. One writer speaks of it as "a jungle rhapsody, an extravagant, impossible botanical tour de force, intensely modern in its Titanic, incoherent magnificence." It is the home of the elephant, the tiger, the panther, the wild boar, several species of deer, and of many strange and beautiful birds.

Desired output

Paragraph 1, Statement 1:
The plains are as flat as the proverbial pancake--a dead monotony of cultivated alluvium, square mile upon square mile of wheat, rice, vetch, sugar-cane, and other crops, amidst which mango groves, bamboo clumps, palms, and hamlets are scattered promiscuously.

Paragraph 1, Statement 2:
In some places the hills rise sheer from this, in others they are separated from the alluvial plains by belts of country known as the Tarai and Bhabar.

Paragraph 1, Statement 3:
The Tarai is low-lying, marshy land covered with tall, feathery grass, beautifully monotonous.

Paragraph 1, Statement 4:
This is succeeded by a stretch of gently-rising ground, 10 or 20 miles in breadth, known as the Bhabar--a strip of forest composed mainly of tall evergreen sal trees (Shorea robusta).

Paragraph 1, Statement 5:
These trees grow so close together that the forest is difficult to penetrate, especially after the rains, when the undergrowth is dense and rank.

Paragraph 1, Statement 6:
Very beautiful is the Bhabar, and very stimulating to the imagination.

Paragraph 1, Statement 7:
One writer speaks of it as "a jungle rhapsody, an extravagant, impossible botanical tour de force, intensely modern in its Titanic, incoherent magnificence.

Paragraph 1, Statement 8:
" It is the home of the elephant, the tiger, the panther, the wild boar, several species of deer, and of many strange and beautiful birds.

Question 2

+15 marksProgramming

A file mydata.csv is present in the current working directory. Use sed to swap the fourth column to the first column.

Sample input

grep,219,10.95,47961
ls,208,10.4,43264
echo,195,9.75,38025
ps,92,4.6,8464
sed,82,4.1,6724
cd,80,4,6400
vi,77,3.85,5929
clear,72,3.6,5184
awk,72,3.6,5184
man,67,3.35,4489

Sample output

47961,219,10.95,grep
43264,208,10.4,ls
38025,195,9.75,echo
8464,92,4.6,ps
6724,82,4.1,sed
6400,80,4,cd
5929,77,3.85,vi
5184,72,3.6,clear
5184,72,3.6,awk
4489,67,3.35,man

Question 3

+15 marksProgramming

A file sample.txt contains multiple paragraphs. As it is a text file, discerning paragraphs could be tricky. To resolve this user wanted to add '---' before and after each paragraph. Write a sed script which will accomplish that.

Sample Input

The plains are as flat as the proverbial pancake—a dead monotony of cultivated alluvium, square mile upon square mile of wheat, rice, vetch, sugar-cane, and other crops, amidst which mango groves, bamboo clumps, palms, and hamlets are scattered promiscuously. In some places the hills rise sheer from this, in others they are separated from the alluvial plains by belts of country known as the Tarai and Bhabar. The Tarai is low-lying, marshy land covered with tall, feathery grass, beautifully monotonous.
This is succeeded by a stretch of gently-rising ground, 10 or 20 miles in breadth, known as the Bhabar—a strip of forest composed mainly of tall evergreen sal trees (Shorea robusta). These trees grow so close together that the forest is difficult to penetrate, especially after the rains, when the undergrowth is dense and rank. Very beautiful is the Bhabar, and very stimulating to the imagination. One writer speaks of it as "a jungle rhapsody, an extravagant, impossible botanical tour de force, intensely modern in its Titanic, incoherent magnificence." It is the home of the elephant, the tiger, the panther, the wild boar, several species of deer, and of many strange and beautiful birds.

Sample Output

---
The plains are as flat as the proverbial pancake—a dead monotony of cultivated alluvium, square mile upon square mile of wheat, rice, vetch, sugar-cane, and other crops, amidst which mango groves, bamboo clumps, palms, and hamlets are scattered promiscuously. In some places the hills rise sheer from this, in others they are separated from the alluvial plains by belts of country known as the Tarai and Bhabar. The Tarai is low-lying, marshy land covered with tall, feathery grass, beautifully monotonous.
---
---
This is succeeded by a stretch of gently-rising ground, 10 or 20 miles in breadth, known as the Bhabar—a strip of forest composed mainly of tall evergreen sal trees (Shorea robusta). These trees grow so close together that the forest is difficult to penetrate, especially after the rains, when the undergrowth is dense and rank. Very beautiful is the Bhabar, and very stimulating to the imagination. One writer speaks of it as "a jungle rhapsody, an extravagant, impossible botanical tour de force, intensely modern in its Titanic, incoherent magnificence." It is the home of the elephant, the tiger, the panther, the wild boar, several species of deer, and of many strange and beautiful birds.
---

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 May 2023 Set 2 paper

The IIT Madras BS System Commands (System Commands) OPPE 2 paper sat on May 2023, in the May 2023 term, set 2: 6 questions for 100 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 May 2023 Set 2 at a glance
TermMay 2023 term
SubjectSystem Commands
Course codeBSSE2001
Questions6
Marks100
Duration180 min
Programming6
Official paperOPPE 2, May 2023 Set 2
Negative markingNo negative marking.
Updated

Other sets that day

More System Commands