Which of the following will output “onetwothree”?

  1. a. for n in one two three ; do echo –n $n ; done

  2. b. for val ; do echo –n $val ; done

  3. for n in one two three ; do echo -n $n ; done

  4. d. foreach n in one two three; do echo –n $n ; done

  5. e. foreach n in one two three { echo –n $n }


Correct Option: C

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) for n in one two three ; do echo -n $n ; done - This option is incorrect because it uses the incorrect syntax for the echo command. The correct option should use a hyphen (-n) instead of an en dash (–n).

Option B) `for val ; do echo -n $val ; done

Find more quizzes: