This `awk` command will take the output from your `srvctl` command - or at least one that's formatted similarly to the one posted in the question - and generate a command you can use to repeat the configuation:
srvctl config database -d MYDB |
awk -F':' '
/^Database unique name/ { dun=$2; gsub("^ *", "", dun) }
/^Oracle home/ { oh=$2; gsub("^ *", "", oh) }
END { printf "srvctl add database -d %s -o %s\n", dun, oh }
'
Output:
srvctl add database -d MYDB -o /path/to/home
Or, to match your requirement more closely:
srvctl config database -d MYDB >srvctl.txt
awk -F':' '
/^Database unique name/ { dun=$2; gsub("^ *", "", dun) }
/^Oracle home/ { oh=$2; gsub("^ *", "", oh) }
END { printf "srvctl add database -d %s -o %s\n", dun, oh }
' srvctl.txt
Output:
srvctl add database -d MYDB -o /path/to/home