I have a line in a file that looks like this:
$db['foo']['database'] = 'bar';
I want to use ack or grep or something to return bar
out of that string. So far I have:
ack '^\$db\['\''foo'\''\]\['\''database'\''\] = '\''([\w_]+)'\' $file
But don't know how to get it to spit out just the first backreference, instead of the whole line.