tldr/pages/common/sed.md

18 lines
475 B
Markdown
Raw Normal View History

2013-12-11 10:50:11 +00:00
# sed
> Edit text in a scriptable manner.
2022-11-12 13:05:16 +00:00
> See also: `awk`, `ed`.
> More information: <https://manned.org/sed.1posix>.
2013-12-11 10:50:11 +00:00
2022-11-12 13:05:16 +00:00
- Replace all `apple` (basic regex) occurrences with `mango` (basic regex) in all input lines and print the result to `stdout`:
2013-12-11 10:50:11 +00:00
2022-11-12 13:05:16 +00:00
`{{command}} | sed 's/apple/mango/g'`
2013-12-11 10:50:11 +00:00
2022-11-12 13:05:16 +00:00
- Execute a specific script [f]ile and print the result to `stdout`:
2022-11-12 13:05:16 +00:00
`{{command}} | sed -f {{path/to/script.sed}}`
2022-11-12 13:05:16 +00:00
- Print just a first line to `stdout`:
2013-12-11 10:50:11 +00:00
2022-11-12 13:05:16 +00:00
`{{command}} | sed -n '1p'`