Name

global

Synopsis

[address] g[!]/pattern/[commands]

Execute commands on all lines that contain pattern or, if address is specified, on all lines within that range. If commands are not specified, print all such lines. Add a ! to execute commands on all lines not containing pattern. See also v.

Examples

:g/Unix/p               Print all lines containing "Unix"
:g/Name:/s/tom/Tom/     Change "tom" to "Tom" on all lines                                                 containing "Name:"

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.