print friendly version

Questions and answers

In Unix, how do I refer to files with names containing a space?

The commands described below need to be entered while logged in to the Unix server.   Normally you'll see a prompt ending with $ when the command interpreter (or shell) is ready for another command.

Suppose you have a file called

my file (with a space between the words my and file)

Then (for example):

  • To view the file without renaming it:
    more   my?file
    (the ? signifies 'any character' and can be used to represent a space)
  • To rename the file and then view it:
    mv   my?file   my_file
    (mv means 'move', or rename)
    more my_file

You can also enclose the entire file name in double-quotes, like this:

more   "my file"


mv   "my file"   my_file

Help us to improve this answer

Please suggest an improvement
(login needed, link opens in new window)

Your views are welcome and will help other readers of this page.


This is question number 212, which appears in the following categories:

Created by Andy Clews on 27 July 2001 and last updated by Andy Clews on 4 August 2015