~/ learn/ comp-325/ cards/ Editing a stream you never open
1 of 10

Substitute the first match per line, then every match

Substitute the first match per line, then every match

Answer

sed 's/port/PORT/' relay.conf sed 's/port/PORT/g' relay.conf

One character apart, and only line 4 of the fixture differs between the two outputs, because it is the only line containing the word twice. Without g, s replaces the first match on each line and moves on.

POSIX.1-2024 (IEEE Std 1003.1-2024) Shell and Utilities: sed. The textbook names sed as a regex tool and never teaches it.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/e76bd209-307b-40da-a2dd-90a12df33763/flashcard utf-8 LF