How do you open a file which has spaces in the filename using Terminal on Mac?

I've seen some pages that say type: "open FileName" and it works for files that are one worded. But I would like to open a picture that is named: "Test Subject.jpg".

I've already tried: "open Test Subject.jpeg" and "open TestSubject.jpeg" but none will open it.

How can I open a picture or video on Terminal if there is more than one word in the "FileName" e.g. Test Subject.jpeg?

  • I'm not sure this is a duplicate. The linked duplicate is regarding quoting around ~, whereas this question supposes no knowledge of quoting even for spaces. – grg Jun 5 '18 at 12:07
  • yes i could not find this anywhere on forum chats but i did end up finding out how eventually watching multiple youtube videos. Thanks though as i did get a correct answer from grg. I accidentally copied the question and put it as an answer. That explains why there is 2 answers and not just the 1 correct one. – Egman23 Jun 8 '18 at 4:32

Either escape the space with a backslash or use quotes.

open Test\ Subject.jpg
open "Test Subject.jpg"

You can also use autocomplete with tab. Type open Test then ⇥ to autocomplete.

Take note of the extension and make sure you use the right one. You've used 3 different extensions in your question, only the right one will open the file. List the contents of the folder with ls.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged .