Operating Systems and Systems Integration Quiz 7: Shell Programming Do not refer to any printed material. No talking or discussion is allowed until the answer sheets are all collected. Review: 1. Here are two arithmetic conditions that are to be used with an if statement: [ $i -lt 5 ] ((i<5)) (A) Both are correct (B) The first is correct but the second is not correct because the ‘$’ is missing from in front of the ‘i’ (C) The first is correct but the second is not correct because the spaces should be put between all the tokens (D) The first is correct but the second is not correct because the operator is wrong; it should be ‘-lt’ (E) The first is wrong, but the second is correct. 2. Which of the following will cause a shell variable var to be defined with the value “value”? (A) $ $var=${value} (B) $ $var = value (C) $ var = value (D) $ var=value (E) $ $var=value 3. A shell script script.sh is executed like this, and the output is shown: $ script.sh 1 2 3 4 5 6 parameters are 1 2 3 4 5 6 The first line of the file script.sh is #! /bin/sh The second line could be: (A) $ parameters are $* $2 $3 $4 $5 $6 (B) $ echo parameters are $0 $1 $2 $3 $4 $5 (C) $ echo parameters are $# $1 $2 $3 $4 $5 (D) $ echo parameters are $@ (E) $ echo parameters are $$ $1 $2 $3 $4 $5 Preparation: 4. This question relates to input and output in the shell: (A) We can perform input with read, output with printf (B) We can perform input with read, output with echo (C) We often use a while loop with read to process input, one line for each iteration of the loop (D) We use redirection to put output into files (E) All the other choices are correct 5. A shell script is written called rename. It can be called in any of the following ways: Nick Urbanik ver. 1.0 Quiz 7: Shell Programming Operating Systems and Systems Integration 2 $ $ $ $ $ rename rename rename rename rename -v -v *.c -v *.c -v -l *.c The ‘-v’, ‘-l’ are called: (A) enumerations (B) test fields (C) parameters (D) param (E) options Nick Urbanik < nicku(at)vtc.edu.hk> ver. 1.0