Hur man kör Shell Script-filer på Windows 10 Använder WSL.
Våldsamt slag is a Unix shell and command language which can run Shell Script files.
- Execute Shell Script file using WSL
- Execute Shell Script using Ubuntu on Windows 10
Execute Shell Script file using WSL
Install WSL or Windows Subsystem for Linux
1. Gå tillInställningarUppdatera & Security\For Developers. KollaDeveloper Mode;
2. Söka efter Windows Feature, och väljer att Turn Windows features on or off;
3. Scroll to find WSL, check the box, and then install it;
4. Reboot to finish installing the requested changes;
5. BASH will be available in the Kommandotolken och PowerShell.
Execute Shell Script Files
1. Öppen Windows PowerShell and navigate to the folder where the script file is available;
2. Typ:
Bash script-filename.sh
It will execute the script, and depending on the file, you should see an output.
On a Linux platform, you usually use SH, but here you need to use BASH.
Execute Shell Script using Ubuntu in dual-boot
Make sure you have Ubuntu or any other Linux distros installed on the target PC in dual-boot with Windows 10. Ubuntu will mount or make all your Windows directories available under/mnt. So the C:\ drive is available at /mnt/C.
Now follow these steps:
- Type Bash in a run prompt, and it will launch the distro prompt.
- Navigate to the folder using the cd command to the folder where the scripts are available.
- Typ sh script.sh and hit enter.
This is false, to use bash like this you NEED to have linux distribution installed