This commands prepends a line at the beggining of yourfile
sed -i 1i"define('WP_CACHE', true);" yourfile
To look for many files named wp-config.php and prepend the same text, type this in the shell:
for i in $(find . -name wp-config.php)
do
sed -i 1i"define('<?php WP_CACHE', true); ?>" $i
done
Run this from the main folder where you have all the WP sites.