I think that I'm missing something obvious, but I've spent a lot of time Googling around and searching stackoverflow, and I can't find an answer. I'm looking for a way to perform an additional sed substitution on a captured group. So, for example, if I have the text:
MD5 (./x y.jpg) = 93845ad8b6fb2797d9f1d7e0622e9270 MD5 (./x y z.jpg) = 93845ad8b6fb2797d9f1d7e0622e9270
I'd like to replace the spaces within the parentheses with underscores and reformat the string to be the filenamemd5.
./x_y.jpg 93845ad8b6fb2797d9f1d7e0622e9270 ./x_y_z.jpg 93845ad8b6fb2797d9f1d7e0622e9270
I'm able to capture the filename, but I don't know how to perform another substitution on the captured group.
echo 'MD5 (./x y.jpg) = 93845ad8b6fb2797d9f1d7e0622e9270' | sed 's/MD5 (\(.*\)) = \(.*\)/\1 \2/'
./x y.jpg 93845ad8b6fb2797d9f1d7e0622e9270