1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add Apply Multiple Substitutions To The Input as a sed til

This commit is contained in:
jbranchaud
2021-03-05 19:04:52 -06:00
parent c652dd86f6
commit 4d1dc0bfe4
2 changed files with 25 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
# Apply Multiple Substitutions To The Input
You can apply multiple substitutions to the input of a `sed` command a couple
ways.
One of those ways is to use the `-e` flag multiple times to define
substitutions that should be _appended_ to the `sed` script.
```bash
$ echo 123 | sed -e 's/3/three/' -e 's/1/one/'
one2three
```
Another way is to define a single string as the `sed` script and separate each
substitution with a `;` (semicolon).
```bash
$ echo 123 | sed 's/3/three/; s/1/one/'
one2three
```
Each of these will run each substitution in the `sed` script sequentially for
each line in the input.