If you've got GNU sed
with the -i
option to overwrite the files (with backups for safety), then:
find . -name '*.rb' -exec sed -i .bak 's/^/ /' {} +
find . -name '*.html' -exec sed -i .bak 's/^/ /' {} +
Etc.
The find
generates the list of file names; it executes the sed
command, backs up the files (-i .bak
) and does the appropriate substitutions as requested. The +
means 'do as many files at one time as is convenient. This avoids problems with spaces in file names, amongst other issues.