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
The following expression matches the pattern [a-z, A-Z and space] and replaces it with \macro{}
[a-z, A-Z and space]
\macro{}
sed -e 's/\[\([a-zA-Z ]*\)\]/\\macro{\1}/g'
In the expression the \( ... \) form a match group that can be referenced later in the substitution as \1
\( ... \)
\1