Как заменить парные квадратные скобки другим синтаксисом на sed?
Я хочу заменить все пары квадратных скобок в файле, например,[some text]
, с\macro{some text}
Например:
This is some [text].
This [line] has [some more] text.
Это становится:
This is some \macro{text}.
This \macro{line} has \macro{some more} text.
The pairs only occur on individual lines, never across multiple lines.
Sometimes there might be more than one pair on a single line, but they are never nested.
If a bracket is found alone on a line, without a pair, then it should not be changed.
Как я могу заменить эти пары скобок с этим кодом?