Multiple choice technology operating systems

How will you substitute the strings in a file using SED?

  1. s/old/new/l

  2. s/old/new/g

  3. s/new/old/g

  4. s/old/new/f

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

The sed command s/old/new/g substitutes all occurrences of 'old' with 'new' in a file. The g flag stands for global replacement, meaning all occurrences on each line are replaced, not just the first. Without g, only the first occurrence per line would be replaced. Option A uses 'l' which is not a valid flag. Option C has the pattern reversed (new/old). Option D uses 'f' which is not a sed flag.