Question 23Asked in UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)

Which of the following commands will output "one two three"?

  1. AFor val; do echo-n $val; done < one two three
  2. BFor one two three; do echo-n-; done
  3. CFor n in one two three; do echo-n $n; done
  4. DFor n in one two three {echo -n $ n}
Show answerHide answer

Correct answer: (C) For n in one two three; do echo-n $n; done

Explanation

The for loop "for n in one two three; do echo -n $n; done" iterates n over the words one, two and three and echoes each, so it gives the output "one two three". So the answer is (c).

From UGC NET Computer Science PYQ, June 2014 (Paper II & III, Selected Questions)

This is question 23 of UGC NET Computer Science PYQ, June 2014 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.