sed
TLDR
Substitute all occurrences of "apple" with "mango" on all lines
SYNOPSIS
sed [options] 'script' [input-file...]
DESCRIPTION
sed (stream editor) is a powerful text processing tool that performs basic transformations on input streams (files or piped data). It reads input line by line, applies specified editing commands, and writes to standard output.
Common operations include search and replace (s///), deletion (d), insertion (i), and printing (p). sed uses regular expressions for pattern matching and supports both basic and extended regex syntax. Address ranges (line numbers or patterns) can target specific lines.
PARAMETERS
-i[suffix], --in-place[=suffix]
Edit files in place; optionally create backup with suffix-e script, --expression=script
Add script commands to execute-f file, --file=file
Read script from file-n, --quiet, --silent
Suppress automatic printing; only print when p command used-r, -E, --regexp-extended
Use extended regular expressions-s, --separate
Treat files as separate rather than single stream-z, --null-data
Separate lines by NUL characters--debug
Annotate program execution--help
Display help--version
Display version
CAVEATS
The -i option modifies files directly; always test with output to stdout first or use backup suffix. Behavior of -i without suffix varies between GNU sed and BSD sed. Regular expression syntax differs between basic (default) and extended (-r) modes.
HISTORY
Created by Lee McMahon at Bell Labs in 1973-1974 as part of Unix. Based on the ed editor's scripting capabilities but designed for non-interactive stream processing. GNU sed extended the original with features like in-place editing and extended regex support.
