How to Open a File from Mac Terminal [Easy Guide]

Give a try to these simple procedures now

Reading time icon 3 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Key notes

  • If you’re a Mac user, you probably encountered Terminal at least once.
  • The Terminal can be a great tool, and in this article, we’ll show you how to open a file in Terminal.
open file in terminal

The Terminal can be a handy tool, especially for advanced users. Unfortunately, many users are unfamiliar with it.

In this article, we’ll change that and show you how to open a file in Terminal. It’s easier than you think, so let’s get started.

How can I open a file in Terminal?

1. Use the open command

  1. Navigate to Applications > Utilities.
  2. Start the Terminal.
    open terminal open file in terminal
  3. Run the following command:
    open ~/Desktop/filename.mp4

After running this command, you’ll open the selected file with the default application for that file type.

You can also open multiple files simply by doing the following:

  1. Navigate to the folder where the files are stored using the cd command in Terminal.
  2. Now run the following command:
    open "file1.mp4" "file2.mp4" "file3.mp4"

You can also open all files with the same file type by using the following command:

open ~/Desktop/*.jpg

By using this command, you’ll open all .jpg files that are located in the Desktop folder.

To open a file with specific software, you need to slightly adjust the command by adding the -a parameter followed by the name of the software that you want to use to handle the file.

In practice, the command would look something like this:

open -a "QuickTime Player" ~/Desktop/filename.mp4

If you want, you can even use a specific path for the app that you want to use to open the file. You can do that like this:

open -a /path/to/chosen_app.app filename.mp4

You can also open a file in the Terminal but choose not to bring the file to the foreground. This can be done with the -g parameter like this:

open -g ~/Desktop/filename.mp4

2. Edit the .bash_profile file

  1. Locate the ~/.bash_profile file and open it.
  2. Add the following line:
    alias WindowsReport='open -a TextEdit'
  3. Save changes.

Now, you have created an alias and can quickly enter specific commands. This can be useful for working with multiple files or long file paths.

To use the alias to open a particular text file, do the following:

  1. Open the Terminal.
  2. Run the following command:
    WindowsReport textfile.txt

Using this method, you can make commands shorter and easier to remember. You can create various aliases by using the commands that we mentioned above.

Also, you can add the Tab key while typing the alias name, making the process much faster.

Opening files in Terminal isn’t that hard, and you should be able to do it easily after following this article’s instructions.

You might also be interested in reading our guide on how to fix the ZSH permission denied issue on a Mac Terminal. And you can also learn how simple it is to open TXF files on your PC as well by applying the methods detailed in our guide.

For any questions or suggestions, please use our comments section below.

More about the topics: mac os