Cmder bash script execution

I created a basic script on Windows.

#!/bin/bash echo Hello 

I am using Cmder, a derivative of ConEmu. I tried changing priviliges with chmod, but they are the same. I do not know how to execute this script. The usual Linux method, which: ./ hello.sh does not work, and by typing only hello.sh, Windows tries to open it, which is bad, since I want it in the console. How to execute this script in ConEmu / Cmder?

+5
source share
3 answers

I noticed that you can run bash from cmder. So I could do it like this:

 > bash $ ./yourScript.sh 

or simpler

 > cat yourScript.sh | bash 

Disclaimer: new to cmder (just loaded) and Linux itself.

+8
source

In my own instance of Cmder, bash [filename] works just fine, and I find it much simpler:

 C:\Users\Conor O'Brien Ξ» type test.sh echo Hello C:\Users\Conor O'Brien Ξ» bash test.sh Hello 
+4
source

If you want to run the script by simply typing its name, a workaround is to create an alias and transfer it to your .bashrc , for example:

 alias scriptName="bash /pathToTheScript/yourScript.sh" 

Or you can create a script inside your .bashrc and make it accessible through a function:

 source /pathToTheScript/yourScript.sh 

where is the script:

 #!/bin/bash function your_function() { yourCode } 
+1
source

Source: https://habr.com/ru/post/1245685/


All Articles