Open a file with spaces in the name in Terminal [duplicate]

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?


Solution 1:

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.