I have the following types of statements on multiple lines in multiple files (these are not necessarily on a line by themselves):
xref:my-awesome-link[This link]
I need to change this to:
xref:this-link[This link]
I have got to:
xref:this link[This link]
using (posting the whole thing which is inside a shell script):
find ./ -name "*.md.adoc" -type f -exec sh -c \
'gsed -i "s/xref\:.*\[\(.*\)\]/xref\:\L\1\E\[\1\]/g" {}' \;
xref\:.*\[\(.*\)\] - the reg exp that captures the string inside [].
\L\1\E\ - does the transformation for lowercase.
What I am struggling with now, is how to transform the xref:this link[This link] to xref:this-link[This link]. I know that I need to transform the matched group but haven't been able to figure out how to do both the lowercase AND replace the spaces with '-'.
I am running this on a MacOS using GNU Sed.
Thanks!