Is there a way to run Bash scripts on Windows?

I bought and I use Windows 7 Ultimate and I like to use it for application development. One of the downsides (as for every OS) is that I cannot run Bash scripts. Is there a way to run Bash scripts on Windows by installing some software? This is normal if it does not work 100%, but as long as the most common functions are available, this should be great.

+82
windows bash
Jun 20 2018-11-18T00:
source share
8 answers

Install Cygwin , which includes Bash among many other GNU and Unix utilities (without which it is unlikely that Bash will be very useful anyway).

Another option is MinGW MSYS , which includes Bash and a smaller set of more important utilities such as awk. Personally, I would prefer Cygwin, because it includes such heavy lifting tools as Perl and Python, which I think I can’t live without them, while MSYS refuses them and suggests that you are going to install them by yourself.

Update : If someone is interested in this answer and works with MS-Windows 10, please note that in MS-Windows 10 there is a Windows Subsystem for Linux feature which, when turned on, allows you to install the Ubuntu user mode image and then launch Bash. This provides 100% Ubuntu compatibility for debugging and running Bash scripts, but this installation is completely autonomous from Windows, and you cannot use Bash scripts to interact with Windows functions (such as processes and APIs), except for limited file access through the DrvFS function .

+64
Jun 20 2018-11-18T00:
source share

If you are looking for something a little more familiar , you can use getGnuWin32 to install all the unix command-line tools that have been ported. This plus winBash gives you most of the unix desktop environment. Add console2 for a better terminal emulator, and you can hardly tell about your windows!

Cygwin is the best toolkit in general, but I ran into problems due to the gap between it and the windows. However, none of these solutions is as good as the native Linux system.

You might want to explore virtualbox to create a virtual virtual machine with your distribution. Install it to share the folder with the os host, and you can use the real Linux development environment and share windows. Just keep an eye on these EOL markers, they get it every time.

+24
Jun 20 2018-11-18T00:
source share

You can always install Cygwin to run the Unix shell on Windows. I used Cygwin extensively with Window XP.

+10
Jun 20 2018-11-18T00:
source share

After installing git -extentions ( https://code.google.com/p/gitextensions/ ), you can run the .sh file from the command line. (No./script.sh is required, just run it as a bat / cmd file) Or you can run them in a "full" bash environment using the MinGW Git bash shell.

I'm not a big fan of Cygwin (yes, I'm sure it is really powerful), so running bash scripts on windows without having to install it is ideal for me.

+9
Sep 04 '14 at 20:27
source share

The best option I can find is Git Windows. Just install it, then right click and select "Git Bash Here", this will open a bash window enter image description here .

This will open a bash window, for example: enter image description here

and Linux commands work ...

I tried the commands 'sh', 'vi', 'ssh', 'curl', etc ...

+9
Mar 12 '16 at 11:28
source share

The best way? Windows 10. Native support for Bash!

+6
Mar 30 '16 at 16:53
source share

To start up, you will most likely have to use Cygwin (which I can't live without using Windows). So right off the bat, +1 for Cygwin. Everything else would be uncivilized.

VERY much, as I said, I recently started using a combination of utilities to easily create PORT Bash scripts for Windows so that my Linux employees can easily run complex tasks that are better handled by GNU utilities.

I can usually transfer a Bash script to batch download in a very short time by opening the source script in one panel and writing the batch file in another panel. The tools I use are as follows:

I prefer UnxUtils for GnuWin32 because [someone, please correct me if I'm wrong] GnuWin utilities usually need to be installed, and UnxUtils are standalone binaries that just work out of the box.

However, CoreUtils does not contain some familiar * NIX utilities, such as cURL, which are also available for Windows (curl.haxx.se/download.html).

I create a folder for projects and always set PATH =. in the .bat file so that no commands other than the main commands of the CMD shell are specified (as well as certain UnxUtils needed in the project folder for the Batch script to function properly).

Then I copy the necessary CoreUtils.exe files to the project folder and link to them in a .bat file such as ". \ Curl.exe -s google.com", etc.

The Bat2Exe program is where magic happens. Once your batch file has been completed and has been successfully tested, run Bat2Exe.exe and specify the path to the project folder. Then Bat2Exe will create a Windows binary file containing all the files in this particular folder, and will use the first .bat, which it uses to use as the main executable file. You can even include the .ico file to use as an icon for the final .exe file that is generated.

I tried several of these types of programs, and many of the generated binaries were marked as malware, but the version of Bat2Exe that I refer to works fine, and the generated .exe files are fully scanned.

The resulting executable file can be launched interactively by double-clicking or run from the command line with parameters, etc., like a normal batch file, except that you can use the functionality of many tools that you will usually use in Bash.

I understand that this is quite a long time, but if I can get a little distracted, I also wrote a Batch script, which I call PortaBashy, which my colleagues can run from a network share that contains a portable installation of Cygwin. Then it sets the% PATH% variable to the normal * NIX format (/ usr / bin: / usr / sbin: / bin: / sbin), etc. And it can either run in the Bash shell, or run the more powerful and beautiful MinTTY terminal emulator.

There are always many ways to accomplish what you are trying to do; it’s just a matter of combining the right tools for the job, and many times it comes down to personal preference.

+3
Sep 23 '15 at 19:13
source share

There is another theoretical possibility: professional versions of Windows have built-in POSIX support, so bash can be compiled for Windows natively.

Sorry, but I still haven't found a compiled ...

+1
Jun 20 2018-11-18T00:
source share



All Articles