I need to get rid of the double square brackets, I only need them once. However I get the error below after this command:
sed -ri 's/("opening_hours": \[\[)(.*?)(\]\]/"opening_hours": \[\2\]/' ./foo.txt
Error: sed: -e expression #1, char 60: Unmatched ( or (
input(foo.txt):
"opening_hours": [["Pendant les expositions : le jeudi de 12h \u00e0 20h et\u00a0du vendredi au dimanche, de 12h \u00e0 18h"]]
"opening_hours": [["\u00d6ffnungszeiten: Fr-Sa, 15-7 Uhr und nach Vereinbarung", "Open hours: Fri-Sat, 3-7pm and by appointment"]]
expected output:
"opening_hours": ["Pendant les expositions : le jeudi de 12h \u00e0 20h et\u00a0du vendredi au dimanche, de 12h \u00e0 18h"]
"opening_hours": ["\u00d6ffnungszeiten: Fr-Sa, 15-7 Uhr und nach Vereinbarung", "Open hours: Fri-Sat, 3-7pm and by appointment"]
For better clarity, I suggest using two s commands:
sed 's/\[//; s/]//' foo.txt
For matching the exact brackets with your shown samples I would suggest to use following. Where I am using 2 substitutions but regex is to match more accurate brackets here.
sed 's/": \[\["/": [":/; s/"\]\]$/"]/' Input_file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With