I am looking for a command in sed which transforms this input stream:
sed
dummy (key1) (key2)dummy(key3) dummy(key4)dummy dummy(key5)dummy))))dummy
You can use this lookbehind based regex in grep -oP:
grep -oP
grep -oP '(?<=\()[^)]+' file key1 key2 key3 key4 key5 key6 key7
Or using awk:
awk
awk -F '[()]' 'NF>1{for(i=2; i<=NF; i+=2) if ($i) print $i}' file key1 key2 key3 key4 key5 key6 key7