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. When you make a purchase using links on our site, we may earn an affiliate commission. Tooltip Icon

Read the affiliate disclosure page to find out how can you help Windows Report effortlessly and without spending any money. 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 an incredibly useful tool, especially for advanced users. Unfortunately, many users aren’t familiar with the Terminal at all.

In this article, we’re going to change that, and we’re going to 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 you can use to enter certain commands quickly. This can be useful if you’re working with multiple files or long file paths.

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

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

Basically, by 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