56

I'm new to Git Bash, just freshly downloaded this for use in my class today, on the first class module it ask me to cd in to different directory and ls the content which works perfectly fine in Git Bash, then it ask me to open a README.md file in a folder with the command:

open README.md

then this error message show up:

bash: open: command not found

I know I cd in to the correct folder, and ls does shows the the README.md file, this is a freshly installed and most updated Git Bash, can't imagine there would be a missing link or altered in this program... what can I do? please help thank you!

I'm using Windows 8 with Git for windows

3
  • 5
    "open" is native on OS X, on linux you can just define it as alias open=xdg-open, on windows I think the equivalent is "start". Hunt up how to associate file types with programs. Commented Mar 5, 2016 at 7:52
  • Great! thank you! at lease I know it is not my Git Bash problem, thank you! Commented Mar 9, 2016 at 4:04
  • You may follow this link. here has the verified answere. unix.stackexchange.com/questions/253376/… Commented Dec 20, 2019 at 5:01

8 Answers 8

116

bash: open: command not found

This error message is trying to tell you that there is no such command called "open". There's nothing wrong with the README.md.

  • OSX - open is a universal opener in OSX
  • Linux - has xdg-open
  • Windows - use start

But you don't need to take the instructions literally. It's not really important how you open the readme file. You can open it with the less command to view the content inside the terminal, or you can open it with notepad for editing in a text editor.

Sign up to request clarification or add additional context in comments.

2 Comments

Great! so I wont worry about it then! at lease I know it is not my system problem, Thank you! I'm thinking if I should get a Mac...
7

open is a linux specific command for Git Bash

You can access your file using the start command like start filename.extension this will open your file using Notepad if you are using Windows 10.

To access file with some text editor you can simply write the command as start texteditorname filename.extension.

To access file with VS Code just simply type start code filename.extension.

To access file with ATOM just simply type start atom filename.extension.

Comments

6

I had the same problem at first when I started using Git Bash in my Windows computer. I wanted to open a folder on my Desktop. I specified the current directory, which was cd Desktop/test and then I gave the command open . to open the 'test' file, and I received bash: open: command not found. I searched through the internet to find a way to open the file, and then finally I tried this one and it worked.

Solution :

  1. Specify the root directory of the file -> cd Desktop
  2. use "start" keyword and give the file name that you want to open -> start test

Comments

2

As described in the first Answer, I used "start" to open my Text File and it works.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
2

This is happening because file opening varies in command line from os to os

so if you are in

  1. mac os - try open in terminal
  2. Linux - has xdg-open
  3. Windows - use start in terminal

this will probably fix your problem, if not then try to open that .gitignore file in vscode

Comments

0

I am using Ubuntu and instead of using open or start, use explorer.exe if you're trying to open in the browser.

explorer.exe filename

for example:

explorer.exe index.html

Comments

0

You could also just try it without "start". In my case, "subl ." and "code ." both work to open the cwd in the respective editors. I assume it is just an alias for "subl start"/"code start".

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

you can add a polyfill for 'open' to your .bashrc or otherwise define/import it

#!/usr/bin/env bash # cross platform polyfill for 'open' (to open a file in the associated app, e.g. the browser) # @usage `open http://example.com` declare -F open &>/dev/null || { if command -v open &>/dev/null; then open(){ command open "$@"; } elif command -v xdg-open &>/dev/null; then open(){ xdg-open "$@"; } elif command -v start &>/dev/null; then open(){ start "$@"; } elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then open(){ if [[ "$1" =~ ^https?:// ]]; then cmd.exe /c start "$@"; else explorer.exe "$@"; fi; } else open(){ echo "please manually open $@"; } fi } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.