Quiz Space

System Commands OPPE 1: May 2025 (May 2025 term)

Question 1

+20 marksProgramming

Motivation

We can iterate over each line from standard input by using while and read commands.

while read -r line; do
    # Process each line here
done

Problem Statement

Given /etc/passwd file as standard input (&0), extract the usernames and convert them to lowercase.

Instructions

  • Write your solution in script.sh shell script file.
  • The script should read the input from standard input (&0).
  • The output should be printed to standard output (&1).
  • No files will be provided, so you need to read from standard input.

Sample Input

root:x:0:0:root:/root:/bin/bash
user:x:1000:1000:User:/home/user:/bin/bash
Sayan:x:1001:1001:Sayan:/home/sayan:/bin/bash

Sample Output

root
user
sayan

Constraints

  • The input will always be in the format of /etc/passwd.
  • Usernames are the first field in each line, separated by a colon (:).

Hints

  • Try using variable manipulation solely to solve this question.

Question 2

+20 marksProgramming

Motivation

Folding

A line of text can be folded into multiple lines in two broad ways:

  • Fixed-width folding: where each line has a fixed number of characters. This can be done using the fold command in Linux.
  • Variable-width folding: where the line is folded based on the content, such as breaking at spaces or punctuation. This can be done using the grep -o command in Linux.
> cat data
123456789
> fold -w 3 data
123
456
789
> grep -o '[0-9]\+' <<< "1,23,456"
1
23
456

Unfolding

Unfolding is the reverse of folding, where multiple lines are combined into a single line. This can be done using the paste command in Linux.

> cat data
1
2
3
> paste -sd'*' < data
1*2*3

Read more about them in man fold, man grep, and man paste.

Problem Statement

You are given a nn dimensional vector in one line. Find the L1 norm of the vector, which is the sum of the absolute values of its components.

Instructions

  • Write your solution in script.sh shell script file.
  • The script should read the input from standard input (&0).
  • The output should be printed to standard output (&1).

Sample Input

[1,-25,4]

Sample Output

30

Constraints

  • The expressions will always be well-formed.
  • The vector can have any number of elements.
  • The components of the vector can be positive or negative integers.

Question 3

+20 marksProgramming

Motivation

Fibonacci Numbers

Fibonacci numbers are a sequence of numbers where each number is the sum of the two preceding ones, usually starting with 1 and 1. The sequence commonly starts as follows: 1, 1, 2, 3, 5, 8, 13, 21, and so on.

Fn=Fn−1+Fn−2F_n = F_{n-1} + F_{n-2}

Problem Statement

You are given a positive integer n. Your task is to print a triangle of n rows consisting of the first n×(n+1)/2n \times (n + 1) / 2 fibonacci numbers.

Instructions

  • Write your solution in script.sh shell script file.
  • The script should read the integer n from standard input.
  • The output should be formatted as a triangle, with each row containing the appropriate number of fibonacci numbers.

Sample Input

4

Sample Output

1
1 2
3 5 8
13 21 34 55

Constraints

  • n is a positive integer.
  • The output should be formatted with each number separated by a space.
  • The last number in each row should not have a trailing space.

2 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 1 May 2025 paper

The IIT Madras BS System Commands (System Commands) OPPE 1 paper sat on May 2025, in the May 2025 term: 5 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 1 May 2025 at a glance
TermMay 2025 term
SubjectSystem Commands
Course codeBSSE2001
Questions5
Marks100
Duration180 min
Programming5
Official paperOPPE 1, May 2025
Negative markingNo negative marking.
Updated

Same OPPE 1, other subjects

More System Commands