Is there any way to run the bash script in windows?

Asked

Viewed 118 times

0

I have a BASH script that is used on LINUX and I need to run it on Windows 10.

Is there any way to run correctly without error?

directory_exist.sh

    #!/bin/bash
    echo "Informe o nome do Diretório"
    read ndir
    if [ -d "$ndir" ]
    then
    echo "Diretório existe"
    else
    `mkdir $ndir`
    echo "Directório criado"
    fi

I call command so:

$ bash directory_exist.sh
  • If you install git, I know you can use git bash... which should be a simpler version. And from.

  • good I’ll test here;

  • Is working.

  • Are you using windows 10? if you are you can make a subsystem for example can use a linux distribution in your windows and you will be able to run bash script

  • Git didn’t satisfy the need, so I’m now using WSL2 with Ubuntu

1 answer

1

Due to the fact that Microsoft operates Azure, and because it is a cloud service, it was necessary to implement bash in Windows 10, even though it is still in beta phase.

So to gain access to Windows 10 bash, you need to follow the steps:

  • Enable developer mode, through Settings -> Updates and Security -> For Developers.

  • Activate Bash by adding the "linux subsystem for windows Feature".

  • Restart your Windows.

Ready, you will find the bash in the start menu.

Obs: I have not used windows 10 for some time, even more in PT-BR, so the names of the steps may be different, but the essence is the same.

Obs 2: There may be differences in commands or how to use.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.