Multiple choice technology architecture

Output of the SED command? sed "s/happy/enchanted/g" chap1

  1. deletes the lines starting with happy.

  2. replaces each occurrence of the word happy found in the file chap1 with the word enchanted.

  3. displays each line in the file chap1 that contains the word happy.

  4. None.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

sed 's/happy/enchanted/g' performs substitution: s command substitutes, 'happy' is the pattern to find, 'enchanted' is the replacement, and g flag means global (all occurrences per line). Every instance of 'happy' in chap1 is replaced with 'enchanted'.