Open file in default program from Terminal

It can be convenient to open a file by launching the default program without first leaving the Terminal. For simplicity, we assume the file is named “file.txt” but it can be any file openable by a program on the computer. This technique works with any file type that has an associated default program on the computer.

  • macOS: open file.txt
  • Linux: xdg-open file.txt
  • Windows: start file.txt