How will you substitute the strings in a file using SED?
-
s/old/new/l
-
s/old/new/g
-
s/new/old/g
-
s/old/new/f
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.