I found it difficult to figure out how to interpret "test data", "test \(data\)" or "\1", but I also found out that I was too much orientated at a bash script that I (with some help) had written almost two years ago, while this could be done with a single command.
Sorry about that. It's like second nature for me so I miss to explain it more in-depth sometimes
"test data" is just some random text string to run with sed.
\(data\) is a regexp buffer command. It will save "data" from the string matched ("test data" in this case).
and \1 is just the position of the buffer. If you add 2 \(<something>\) then the first is \1 and the second is \2