Search⌘ K
AI Features

SED substitutions

Explore the SED substitute command to effectively replace and modify text patterns in files and streams. Learn how to use flags, addresses, and various delimiters for targeted text transformations. Understand practical options like in-place editing and combining commands to streamline text processing tasks in Bash.

We'll cover the following...

The format for the substitute command is as follows:

    [address1[ ,address2]]s/pattern/replacement/[flags] 

The flags can be any of the following:

  • n replace nth instance of pattern with replacement
  • g replace all instances of pattern with replacement
  • p write pattern space to STDOUT if a successful substitution takes place
  • w file Write the pattern space to file if a successful substitution takes
...