Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

sed command returns error about Unmatched (

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):

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"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 :

I suggest:

sed 's/\[//; s/]//' foo.txt
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading