How can I convert tabs to spaces in every file of a directory (possibly recursively)?
Also, is there a way of setting the number of spaces per tab?
My recommendation is to use:
find . -name '*.lua' -exec ex '+%s/\t/ /g' -cwq {} \;
Comments:
sed
is a stream editor. Use ex
for in place editing. This avoids creating extra temp files and spawning shells for each replacement as in the top answer. find|xargs
instead of find -exec
. As pointed out by @gniourf-gniourf this leads to problems with spaces, quotes and control chars in file names cf. Wheeler.