I want to run a command in CMD so it executes in Bash.
For example, open bash.exe "cd .." and this should open Bash, run cd... (I'm aware my example does not work).
Any thoughts and ideas?
11 Answer
I want to run a command in CMD so it executes in Bash.
Use wsl.exe:
Run Linux tools from a Windows command line
Run Linux binaries from the Windows Command Prompt (
CMDorPowerShell) usingwsl.exe <command>.Binaries invoked in this way:
- Use the same working directory as the current
CMDorPowerShellprompt.- Run as the WSL default user.
- Have the same Windows administrative rights as the calling process and terminal.
For example:
C:\temp> wsl ls -la <- contents of C:\temp ->The Linux command following
wsl.exeis handled like any command run in WSL. Things such as sudo, piping, and file redirection work.
Note:
If you're running Creators Update or Anniversary Update, jump to the Creators/Anniversary Update section.
Source Windows interoperability with Linux | Microsoft Docs
5