4

Hye , where can I run my program in bash? I writed a code in bash and I want to check that it's really works , so how can I do it?

I tried to search online compilers in the internet , but my program creates folders (by mkdir for example) so and it's not allows me to see the folders.

Note: My computer's operating system is windows.

lubgr
  • 37,368
  • 3
  • 66
  • 117
  • You can check your script at [ShellCheck.net](https://www.shellcheck.net/). I'm not sure where there is an online shell you can use as a sandbox. – David C. Rankin Jul 05 '18 at 06:55
  • An alternative would be to create a vm with a linux distro or [install Bash in windows](https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10) – leopal Jul 05 '18 at 06:56
  • The question is not clarifying. Please add some detailed description of what your program like. What do you mean by coding in a bash? Is it something like a vim? – Qoros Jul 05 '18 at 06:56
  • @DavidC.Rankin If I write for example something like that `#!/bin/sh mkdir mydir` , how can I see the directories? – WantToKnowMath Jul 05 '18 at 06:57
  • You can run Cygwin on Windows. – Barmar Jul 05 '18 at 06:58
  • @WantToKnowMath -- OK, I get it. You want to run your script and then look and see that the directories were in fact created. You will need a shell for that. You can also just add `mkdir mydir || { echo "directory creation failed" >&2; exit 1; }` to have your script validate it was created. You can also check if `"$PWD"` is *writeable* to know whether you can create the directory before you call `mkdir` (and use `mkdir -p` which will create any subs, as required, and issue no error if the directory already exists) – David C. Rankin Jul 05 '18 at 07:04
  • @DavidC.Rankin I am downloaded `Cygwin64 Terminal` , what is in fact the current directory? And how can I starts to work there? while I write `ls` - it's give me empty line.. – WantToKnowMath Jul 05 '18 at 07:10
  • How can I open the current directory? – WantToKnowMath Jul 05 '18 at 07:16
  • It will depend. On Linux the default user directory is usually `/home/username`, I suspect on windows it will be `%userprofile%`. See [What is the alternative for ~ (user's home directory) on Windows command prompt?](https://stackoverflow.com/questions/9228950/what-is-the-alternative-for-users-home-directory-on-windows-command-prompt) (when you open a terminal it will automatically place you in your default directory -- which you should be able to discern from the prompt itself) If not, just type `dir` or `ls`. – David C. Rankin Jul 05 '18 at 07:17
  • I tried to write `pwd` and I get name of directory that doesn't really exists.. can I talk with you for some seconds in the chat? – WantToKnowMath Jul 05 '18 at 07:19
  • (How can I chat with you?) – WantToKnowMath Jul 05 '18 at 07:22
  • That's a good question. Hold on, I just booted windows so I can help further. There is usually a chat link that pops up. Let me look around. – David C. Rankin Jul 05 '18 at 07:27
  • Oh!, You don't yet have enough reputation to chat. Looks like you have your answer. If you are still stuck. Drop another comment. – David C. Rankin Jul 05 '18 at 07:29

1 Answers1

3

You can run bash on Windows by installing the Linux subsystem (Windows 10) or by installing Cygwin or by installing GIT for Windows (which includes bash).

ewramner
  • 5,810
  • 2
  • 17
  • 33
  • I am downloaded `Cygwin64 Terminal` now, what is in fact the current directory? And how can I starts to work there? while I write `ls` - it's give me empty line.. – WantToKnowMath Jul 05 '18 at 07:11
  • How can I open the current directory? – WantToKnowMath Jul 05 '18 at 07:16
  • If you run a Cygwin terminal it probably starts in your home directory. Search for "cygwin beginners guide" or something like that and you will get details, this is not the place for a Cygwin tutorial. It is a big topic. – ewramner Jul 05 '18 at 07:22
  • Can I open the current directory like in windows? Namely, while I type in the "search" the name of the current that I get from `pwd` - I don't find it in my windows. – WantToKnowMath Jul 05 '18 at 07:26