🎴 Flashcard Mode
Linux/Unix Operating Systems Commands and Shell Scripting
Card1 / 20
Mastered0
Review0
QuestionClick to flip
In vi if we want to replace any string e.g. "NAME" with "name" from line number 1 to 10 only, what command we can use?
AnswerClick to flip back
A
:1,10s/NAME/name/
💡 Explanation:
In vi/vim, line ranges are specified using a comma separator, so :1,10s/NAME/name/ correctly substitutes the string on lines 1 through 10. Using % affects the entire file, omitting the range affects only the current line, and :1-10s is invalid syntax.