MacOS – open a text file in Preview from the Terminal

command linefilemacospreviewterminal

I know that I can open a file with an external program from the Terminal with open, and that works for most applications. However, when I try to use a command like open -a Preview info.txt, it launches Preview, but the file is not opened.

I am on Mavericks 10.10.2.

Is there a way to use the open command (or any other built-in command) to actually open a file in Preview from the Terminal?

Best Answer

Preview only works with PDF files and some image files (png, jpg, gif, tiff, bmp) so you won't be able to open a text file on Preview.

To open your info.txt file from terminal you need to choose an application that can open text files, like TextEdit or any other text editor.

You also could use open -e file, to open any file using TextEdit.