3

In MSYS Bash I get:

$ cd ~             
$ pwd              
/c/Users/antonio 

but:

$ cd / 
$ pwd              
/

Can I get the full Windows absolute path from Bash?

1
  • The possibly easiest option is to use MSYS path translation: cmd.exe //c echo ~ (mixed path style) and let | sed 's|/|\\|g' convert it to windows path if necessary. If you don''t want to use a windows binary and sub-"shell" thenyou may repolace it by { pushd ~ 1>/dev/null && pwd -W && popd 1>/dev/null ; } - but that only works for existing folders not for files or non-existing folders Commented May 4 at 17:56

1 Answer 1

4

In recent versions, e.g. MSYS2, you can use:

~$  cygpath -w /
C:\path\to\root

or with a mixed path style:

~$  cygpath -m /
C:/path/to/root

Similarly, you might use:

~$  cygpath -w ~
C:\path\to\home
~$  cygpath -m ~
C:/path/to/home

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .