vijay
vijay

Reputation: 10997

Can I run a Linux shell script in Windows?

I created Shell Script on Linux and it runs fine.

Now I want to run the same script on Windows using gitbash. (Only filepath changed for windows)

I am confused:

or

According TO differences-between-windows-batch-and-linux-bash-shell-script-syntax

Upvotes: 1

Views: 17808

Answers (2)

user1766169
user1766169

Reputation: 1987

You can use Git Bash

It depends on how advanced the scripts are, but simple scripts can be executed in Git Bash.

test.sh contains:

#!/bin/bash
echo Hello World!

Execute script:

./test.sh

Output:

Hello World!

Git Bash vs Cygwin

To answer your question:

@fedorqui in my learning 'cygwin' And 'gitbash' do same stuff for windows

Git Bash

Git Bash is lightweight and only aims to handle:

  • version control
  • a shell that runs commands

Read more: http://openhatch.org/missions/windows-setup/install-git-bash

Cygwin

  • a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.
  • a DLL (cygwin1.dll) which provides substantial POSIX API functionality.

Read more: https://www.cygwin.com/

Upvotes: 2

fedorqui
fedorqui

Reputation: 289525

Of course you can. There is a tool called cygwin that allows you to do so.

Note that you have to check what the paths are. If so, go to the path you are willing to work on and do pwd. This way, you will get the Windows\kind\of\path.

I use it all the time and it works pretty fine.

Upvotes: 3

Related Questions