WSL — Convert Windows Path to Linux Path in Shell

Why we do this ?

Because the volume parameter of docker-compose only accepts WSL format

How do this ?

The test command realized by the sed command is as follows.

$ echo "c:/Project/test" \
| sed -E 's/^(\w+)+/\L\1/g' \
| sed -e 's/\\/\//g' \
| sed -e 's/://g' \
| sed -e '/^\//!s/^/\//g'


  • sed -E ‘s/^(\w+)+/\L\1/g’ → Lowercase initial letters
  • sed -e ‘s/\\/\//g’ → Convert [] to [/]
  • sed -e ‘s/://’ → Remove [:]
  • sed -e ‘/^\//!s/^/\//g’ → If it does not start with [/], add [/] at the beginning

How use this ?

If we run this the output should be like below:

$ sh

 by the author.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


DevOps Consultant. I’m strongly focused on automation, security, and reliability.