fetch string and insert later

"are you billy_smith ?"

replace with

"are you billy_smith ?
my name is billy_smith"

how to fetch the name "billy_smith" and using it later
I need sed script to do this, any one can help? Thanks

Try something like this,

echo "Are you Bill ?" | sed 's/.* \(.*\) ?/My name is \1/g'

Thanks
Nagaraj G

Does it need to be using sed? I don't think that's straightforward...

Thanks, Can i just get the "name" and set it to $name , so that I can reuse $name later

You only have one "variable" in sed, which is called the "hold space". You can copy or append the current "pattern space" to the "hold space", or you can exchange the two, but inserting the contents of one in the middle of the other is difficult.

You would do much better with awk or perl or similar.

You are right, Thanks,
there is a .sh file to do replacement.sed
what i can do is to modify the replacement file.
how can i use awk in .sed.
Thanks

Sorry, I can't make sense of what you typed.