I am looking for a command in sed which transforms this input stream:
dummy
(key1)
(key2)dummy(key3)
dummy(key4)dummy
dummy(key5)dummy))))dummy
Perlishly I'd do:
my @all_keys;
while ( ) {
push ( @all_keys, m/\((.+?)\)/g );
}
print join ("\n",@all_keys);
__DATA__
dummy
(key1)
(key2)dummy(key3)
dummy(key4)dummy
dummy(key5)dummy))))dummy
dummy(key6)dummy))(key7)dummy))))
This assumes that 'keys' match the \w in perlre (alphanumeric plus "_",)
(If you're not familiar with perl, you can pretty much just swap that for and pipe the data straight to your script - or do more interesting things with @all_keys)