Friday, May 31, 2013

Space, I need space

This is nothing new, but it bears repeating so here we are.  Spaces in filenames under Linux are an annoyance, but one that isn't that hard to deal with.  How do I deal with them?

In one offs, the \.  So `ls Annoying\ File\ With\ Spaces`

How to kill the space?
rename 's/ /_/' *
will replace spaces with _ for all files/dirs in the current directory.

How to deal with spaces while using find?
find . -name \*wav -print0 | xargs -0 ls
This terminates files with the null character instead of a space. Both xargs and find need to do this.