04月23, 2018

Run Linux tools from a Windows command line

Run Linux tools from a Windows command line

CMD or PowerShell prompt

C:\temp> wsl ls -la
total 6
drwxrwxrwx 0 root root 512 Apr 10 18:01 xx
...
C:\temp> wsl sudo apt-get update
[sudo] password for username:

Example mixing WSL and Windows commands:

C:\temp> wsl ls -la | findstr "doc"
drwxrwxrwx 0 root root 512 Apr 20 16:01 doc
findstr "hello" a.txt
hello,good man.
dir | wsl grep lib
04/20/2018 09:26 PM     14  lib.bat
C:\temp> wsl ls -la > out.txt

The commands passed into wsl.exe are forwarded to the WSL process without modification. File paths must be specified in the WSL format.

Example with paths:

C:\temp> wsl ls -la /proc/cpuinfo
-r--r--r-- 1 root root 0 Apr 20 18:00 /proc/cpuinfo
C:\temp> wsl ls -la "/mnt/c/Program Files"

本文链接:https://harry.ren/post/run-wsl-from-windows.html

-- EOF --

Comments