Locate a file and then opening the file using the command line in GitBash

1.3k views Asked by At

I am new to GitBash. I am using GitBash in Windows 10. I started at the home directory and following are the commands/steps I have followed:

  1. ls.
  2. cd Documents.
  3. ls and found the docx file that I wanted to open.
  4. ran open and the name of the document with .docx and it came out bash

open: command not found.

I am trying to open that file so I can get to the file path. Thanks!

2

There are 2 answers

1
Anuj Garg On

use

start <filename>

Run command to open the docx file

3
stud3nt On

You have to perform below steps to add winword.exe path in the PATH variable and then will be able to open .docx files from gitbash.

  1. Set winword.exe file location path to PATH variable using:
PATH=$PATH:'/C/Program Files/Microsoft Office/root/Office16'

I'm using Microsoft Office 2016, so your path might differ based on the version of Microsoft office you are using.

  1. Run command to open the docx file
winword '/C/Users/Admin/Desktop/Test.docx'