OSCP Linux Practice Exam

Access More Questions
In the following sed command what is the g used for? sed 's/bob/jake/g'
Correct Answer:
It means that if there are more instances of 'bob' on one line, more than the first will be replaced; normally only the first 'bob' on each line would be replaced.
Explanation:
The g flag in a sed substitution enables global replacement. In the command sed 's/bob/jake/g', sed looks for every occurrence of bob on each input line and replaces all of them with jake. Without the g flag, only the first bob on each line would be replaced, leaving others unchanged. This flag operates per line, since sed processes input one line at a time. Other flags exist for different behaviors, but g specifically makes the substitution apply to all matches within a single line.

Access more questions from this quiz

Continue to OSCP Linux Practice Exam for more practice questions and the full quiz experience.

Access More Questions