Skip to content

Commit

Permalink
Add example for sed
Browse files Browse the repository at this point in the history
Add a line after the line that matches the pattern (e.g. add a new line with "world" after the line with "hello")
  • Loading branch information
onceupon authored Aug 10, 2023
1 parent 6576e5a commit 212326d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ sed '$a\'

##### Add string to beginning of every line (e.g. 'bbo')
```bash
sed -e 's/^/bbo/' file
sed -e 's/^/bbo/' filename
```

##### Add string to end of each line (e.g. "}")
Expand All @@ -577,6 +577,13 @@ sed -e 's/$/\}\]/' filename
sed 's/.\{4\}/&\n/g'
```

##### Add a line after the line that matches the pattern (e.g. add a new line with "world" after the line with "hello")
```bash
sed '/hello*/a world' filename
# hello
# world
```

##### Concatenate/combine/join files with a separator and next line (e.g separate by ",")
```bash
sed -s '$a,' *.json > all.json
Expand Down

0 comments on commit 212326d

Please sign in to comment.