2013-12-11 21:50:11 +11:00
|
|
|
# sed
|
|
|
|
|
2018-06-26 17:19:31 +02:00
|
|
|
> Edit text in a scriptable manner.
|
2022-11-12 23:05:16 +10:00
|
|
|
> See also: `awk`, `ed`.
|
2023-12-31 09:58:18 -03:00
|
|
|
> More information: <https://manned.org/man/sed.1posix>.
|
2013-12-11 21:50:11 +11:00
|
|
|
|
2022-11-12 23:05:16 +10:00
|
|
|
- Replace all `apple` (basic regex) occurrences with `mango` (basic regex) in all input lines and print the result to `stdout`:
|
2013-12-11 21:50:11 +11:00
|
|
|
|
2022-11-12 23:05:16 +10:00
|
|
|
`{{command}} | sed 's/apple/mango/g'`
|
2013-12-11 21:50:11 +11:00
|
|
|
|
2022-11-12 23:05:16 +10:00
|
|
|
- Execute a specific script [f]ile and print the result to `stdout`:
|
2016-02-27 14:23:24 +01:00
|
|
|
|
2022-11-12 23:05:16 +10:00
|
|
|
`{{command}} | sed -f {{path/to/script.sed}}`
|
2016-02-27 14:23:24 +01:00
|
|
|
|
2022-11-12 23:05:16 +10:00
|
|
|
- Print just a first line to `stdout`:
|
2013-12-11 21:50:11 +11:00
|
|
|
|
2022-11-12 23:05:16 +10:00
|
|
|
`{{command}} | sed -n '1p'`
|