How to run Shell scripts in Windows

Siladittya Manna
The Owl
Published in
1 min readJan 31, 2023
Source

Training machine learning or deep learning models can be automated by using shell scripts in Linux-based PCs. Can we run the same shell scripts on Windows without changing a line of code?

YES, we can. But that will require a bit of work.

1. Using bash on Windows to run Shell scripts

Installing Cygwin, MinGW, or Git Bash on Windows and adding the path where it is installed to the Environment variables will allow us to run “.sh” files on Windows from Command Prompt.

2. Converting “.sh” file to “.bat” file

.bat” extensions are used for batch scripts, which are also used to automate tasks on Windows. Commands for Shell scripting and Batch scripting are not exactly the same, but commands from shell scripts can be converted for like-to-like commands in batch scripts.

A simple converter can be found here: https://daniel-sc.github.io/bash-shell-to-bat-converter/

However, this tool does not support converting loop conversion from shell to batch. Any user can do so by studying the tutorials given below:

  1. https://www.section.io/engineering-education/dive-into-batch-scripting-language/
  2. https://en.wikibooks.org/wiki/Windows_Batch_Scripting
  3. https://www.youtube.com/playlist?list=PL8WTXLSrtyWrQ5Tl50zkTeRc3bATyHRbX
  4. https://www.youtube.com/playlist?list=PL69BE3BF7D0BB69C4

Tutorials for Shell scripting:

  1. https://www.shellscript.sh/
  2. https://www.youtube.com/playlist?list=PLS1QulWo1RIYmaxcEqw5JhK3b-6rgdWO_
  3. https://www.youtube.com/playlist?list=PL7B7FA4E693D8E790
  4. https://www.youtube.com/playlist?list=PLBf0hzazHTGMJzHon4YXGscxUvsFpxrZT

--

--

Siladittya Manna
The Owl

Senior Research Fellow @ CVPR Unit, Indian Statistical Institute, Kolkata || Research Interest : Computer Vision, SSL, MIA. || https://sadimanna.github.io