Tuesday, August 16, 2022
apps@conference.yunohost.org
August
Mon Tue Wed Thu Fri Sat Sun
1 2 3 4 5 6 7
8 9 10 11 12 13
14
15
16
17 18
19
20
21
22 23
24
25
26
27
28
29
30
31
       
             

[08:56:58] <Dante> Hi 😄 any wiz of `sed` and similar alternatives could help me with the following, I'm trying to delete matching lines between two matches, this is what I tried so far: `sed '/permissions:/,/relay:/{/:admin/d;}'`but doesn't seem to work :(

Basically I want to be able to delete only stuff that's between `permissions:` and `relay:`
```
permissions:
"*": relay
#"@admin:example.com": admin
"Your;main;Matrix;account": admin

# Settings for relay mode
relay:
```
[08:57:30] <Dante> Hi 😄 any wiz of `sed` and similar alternatives could help me with the following, I'm trying to delete matching lines between two matches, this is what I tried so far: `sed '/permissions:/,/relay:/{/:admin/d;}'`but doesn't seem to work :(

Basically I want to be able to delete stuff between `permissions:` and `relay:` only

```
permissions:
"*": relay
#"@admin:example.com": admin
"Your;main;Matrix;account": admin

# Settings for relay mode
relay:
```
[08:57:48] <Dante> Hi 😄 any wiz of `sed` and similar alternatives could help me with the following, I'm trying to delete matching lines between two matches, this is what I tried so far:
`sed '/permissions:/,/relay:/{/:admin/d;}'`but doesn't seem to work :(

Basically I want to be able to delete stuff between `permissions:` and `relay:` only

```
permissions:
"*": relay
#"@admin:example.com": admin
"Your;main;Matrix;account": admin

# Settings for relay mode
relay:
```
[10:53:06] <Aleks> Dante: ah yes this is hell because sed only works line-by-line
[10:53:10] <Aleks> mutliline sed is hell
[10:54:07] <Aleks> perl does allow multiline search and replace more easily tho, for example : https://github.com/YunoHost/yunohost/blob/buster/src/yunohost/data_migrations/0021_migrate_to_bullseye.py#L208
[10:55:52] <Aleks> so maybe something like `perl -i~ -0777 -pe 's/permissions:\n.* relay:/permissions:\n relay:/g' /your/file`
[13:17:54] <Dante> thanks again Aleks didn't thought of `perl` but could work fine, I'll try later 😄
[14:00:54] <Aleks> (me neither I just learned this from a stack overflow thread 😅)