Issue
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"]
Solution
For better clarity, I suggest using two s
commands:
sed 's/\[//; s/]//' foo.txt
Answered By - Cyrus Answer Checked By - Mary Flores (WPSolving Volunteer)