Name

sub

Synopsis

sub(regex, str [, target])

Substitute str for first match of the regular expression regex in the string target. If target is not supplied, default to $0. Return 1 if successful; 0 otherwise. Use & in the replacement string to stand for the text matched by the pattern.

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.