# man > ed(1)

---
type: CommandReference
command: ed
mode: man
section: 1
source: man-pages
---

## Quick Reference

- `ed` — start interactive editor with empty document
- `ed -p '> '` — start with specific prompt
- `ed -v` — verbose mode (equivalent to `H` command)
- `ed -q -s` — quiet/script mode (suppress diagnostics, byte counts, '!' prompt)
- `ed -l` — loose exit status (exit 0 even if command fails)
- `ed path/to/file` — edit a specific file (shows byte count of loaded file)
- `,s/regex/replacement/g` — replace string on all lines (interactive)
- `q` — exit ed (interactive)

## Name

ed — line-oriented text editor

## Synopsis

`ed [options] [file]`

## Options

- `-h, --help` — display help and exit
- `-V, --version` — output version information and exit
- `-E, --extended-regexp` — use extended regular expressions
- `-G, --traditional` — run in compatibility mode
- `-l, --loose-exit-status` — exit with 0 status even if a command fails
- `-p, --prompt STRING` — use STRING as an interactive prompt
- `-r, --restricted` — run in restricted mode (red)
- `-s, --quiet, --silent` — suppress diagnostics, byte counts and '!' prompt
- `-v, --verbose` — be verbose; equivalent to the `H` command
- `--strip-trailing-cr` — strip carriage returns at end of text lines

If *file* begins with '!', read output of shell command.

## Examples

shell
# Start editing an empty document
ed

# Edit a file
ed document.txt

# Start with a custom prompt
ed -p '> '

# Verbose mode (shows detailed errors)
ed -v file.txt

# Quiet mode for scripting
ed -s file.txt

# Interactive: replace 'foo' with 'bar' on all lines
, s/foo/bar/g

# Interactive: save and quit
w
q

# Quit without saving
q!
## See Also

Full documentation: [info ed](https://www.chedong.com/phpMan.php/man/ED/1/markdown) (Texinfo manual)

## Exit Codes

- `0` — normal exit
- `1` — environmental problems (file not found, invalid flags, I/O errors, etc.)
- `2` — corrupt or invalid input file
- `3` — internal consistency error (bug) causing panic