Spaces in filenames

Today’s desktop users are familiar with filenames including spaces. The hell begins when those users can store files on a unix server using a windows desktop.

This morning I had to change the permissions of a bunch of files on solaris. Normally i would just type in the command and run it …. but NOT this morning. A lot of files which i had to access contained spaces pffff.

The unix shell is very powerfull … so I knew there was a simple solution. I am just writing it down here so you can use it in the future:

find . -type d | sed -e 's/ /\\ /g' | xargs sudo chmod 777

One Response to “Spaces in filenames”

  1. Danny Says:

    You can also escape spaces by putting the filename between quotes like this:
    sed -e ’s/^.*$/”&”/’

Leave a Comment