Convert Windows path to Linux path

2

I am using .bat and .sh from Windows with CMD and Git Bash respectively.

The problem is that I need to convert a path with Windows format C:\Desktop\install-new-cashier to UNIX format to be read from the .sh that I run in Git Bash as the next /C/Desktop/install-new-cashier ; any way to do it?

    
asked by Mario Hemanuel VU 22.07.2017 в 02:39
source

2 answers

2

It will depend mostly on the environment, if bash is executed in a msys or cygwin environment then there is a progam in PATH with the name cygpath , in msys cygpath is a .bash file that depending on the version can be really very simple giving rise to errors (for example if the path does not exist), however ignoring the possible errors, the way to do it is as follows

$ cygpath C:\Users\usuario\Desktop\\install-new-cashier
  /c/Users/usuario/Desktop/install-new-cashier

Inverse process, stored as variable:

$  variable=$(cygpath -w /c/Users/usuario/Desktop/install-new-cashier)
$  echo $variable
   C:\Users\usuario\Desktop\install-new-cashier

You can be guided at this response , or consult the documentation of your bash provider directly

    
answered by 22.07.2017 / 04:31
source
0

Test using relative routes. If you execute the command from Desktop should work.

For example, if you're already in Desktop :

git add ./install-new-cashier/

should work in the Windows Git and in any operating system type * nix.

    
answered by 22.07.2017 в 03:04