I want to replace all pairs of square brackets in a file, e.g., [some text], with \\macro{some text}, e.g.:
[some text]
\\macro{some text}
This is some [text]. Th
sed -e 's/\[\([^]]*\)\]/\\macro{\1}/g' file.txt
This looks for an opening bracket, any number of explicitly non-closing brackets, then a closing bracket. The group is captured by the parens and inserted into the replacement expression.