Tuesday, September 13th, 2005

Linux Command Line - Dealing with spaces in filenames


A friend asked me today how to say cd into a directory that has a space in its name… (a newbie)… If anyone else has wondered the same, the answer is to use the backslash just before the space… so to enter a directory called “This Dir” you would enter at the prompt:

# cd This\ Dir

This works for files as well (i.e. # cat This\ File.txt) For long filenames or dirs, try using tab complete (start typing the name then hit tab and it will fill in the rest of the filename for you).

Posted by md on September 13th, 2005 | Filed in Technology |


One Response to “Linux Command Line - Dealing with spaces in filenames”

  1. February 3rd, 2008 at 3:29 pm

    R Smith said:

    Thank you for this simple fact. I have been using Ubuntu for about a month now, and I have been forced to use many was to get around the fact that command line would not reconginse the filenames with spaces in them. Thank you good sir



Please leave a Comment