Forum Question: How Do I Open a File In Terminal That Has Space In Its Name?

I am just playing around with the terminal but I can’t figure out how to open files in terminal if it has space in the name, for example “funny thing.rtf” Appreciate all help. Thanks in advance.
—–
Vegard Falmår

Comments: 3 Responses to “How Do I Open a File In Terminal That Has Space In Its Name?”

    11/6/11 @ 9:32 am

    There are at least two ways two do it.
    The first is to simply unescape space characters with a backslash. For example:
    open funny\ thing.rtf
    The second is to use quotes to encode the file name.
    open "funny thing.rtf"
    If it is a long file name or a long path, you can also drag and drop the file to the Terminal window to insert its filename. For instance, you would type the command (open) and then drag the file from Finder window or desktop to the Terminal and it would insert the file name or full path, like: /Users/username/Desktop/my\ file\ name.rtf
    Another thing you can do is use file name autocomplete. So you type the command, and then space, and then the first few letters of the file name (funn) and then hit the Tab key. If that is the open file in the current directory start starts with those letters, then the rest of the file name is filled in.

      Vegard Falmår
      11/6/11 @ 10:45 am

      Thanks a lot

      ckp
      10/31/12 @ 12:54 pm

      thanks for the drag and drop tip…worked great.

Comments Closed.