mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-12-22 08:16:36 +00:00
Add example for sed
Add a line after the line that matches the pattern (e.g. add a new line with "world" after the line with "hello")
This commit is contained in:
parent
6576e5a685
commit
212326d7a3
@ -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. "}")
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user