views:

7025

answers:

9

Is there anything like bash shell in Windows with at least basic set of frequently used commands like ls, pwd, tail, etc?

+1  A: 

Use Cygwin - it comes with most of what you need.

Jonathan Leffler
+22  A: 

Cygwin will allow you to run a Bash shell (apart from many other POSIX environment software) under Windows.

Alan Haggai Alavi
Yay for cygiwin (I see it's unanimous, but you beat the other two responders by a nose, so, +1 to you!-).
Alex Martelli
Thanks for the recommendation.
SeasonedCoder
+1 for the marvelous Cygwin switching Windows to something one can actually use productively.
Boldewyn
+4  A: 

There is also SFU (services for UNIX), or nowadays SUA (subsystem for UNIX based applications), which is (at least the latter) a POSIX compatiblity layer including a UNIX VFS and many common UNIX tools, like, to answer your question, a Korn shell.

TheBonsai
You can even install Gentoo on Windows using SFU/SUA: http://mirrors.kernel.org/gentoo/experimental/prefix/x86-interix/iso/
ephemient
Not what I usually want to do, but nice :)
TheBonsai
I used to use [UWIN](http://www.research.att.com/sw/tools/uwin/) before SFU or Cygwin matured; both UWIN and SFU/SUA have the "problem" of feeling like a snapshot of UNIX from 20 years ago, which is quite disconcerting once you've gotten used to GNU/Linux. Gentoo/Interix kinda solves this... though Cygwin is the easiest solution :)
ephemient
+8  A: 

It's not bash compatible, but if you haven't used it yet, you should really check out Powershell. pwd and ls are built in aliases already. They do essentially the same thing as their *NIX counterpart, only instead of returning a string, they return .NET objects.

pwd, returns a PathInfo object, so if you want the current drive name, just run:

(pwd).Drive

ls returns an array of DirectoryInfo and FileInfo objects, so listing last access time is simply:

ls | select LastAccessTime

Or append the current time to every .log file in a directory structure:

(ls . -Include *.txt -Recurse).AppendText([DateTime]::Now)

For tail functionality, try cat -wait. Or else take a look at this script which gives somewhat closer functionality.

Eclipse
+1 PowerShell is the way to go - way more powerful than bash or any of the other *nix shells, IMHO - since it's based on piping objects from cmdlet to cmdlet, rather than just text which needs to be parsed over and over again...
marc_s
+12  A: 

Msys should also be mentioned. It is a rather good set of all the important GNU tools for Windows, including bash. It also makes it possible to run the tools from the normal windows CMD-prompt. So if you use CMD from time to time you still have the usual tools like ls and grep available. It also feels more lightweight than Cygwin, at least to me.

sth
You can also do this with Cygwin - just add C:\cygwin\bin to your path environment variable (or replace the "C:\cygwin" part with the path to your local cygwin installation).
Steg
+1  A: 

As mentioned by almost everyone Cygwin is pretty good, although it's a little on the "heavy" side. If you're looking for something lighter, check out MinGW (and MSYS).

Tal Pressman
+2  A: 

Unxutils is a set of standalone unix utilities that run on windows. You could take a look at it and see if it offers the things you need. This is nice because you don't need a full install of cygwin.

Andy White
+4  A: 

GnuWin32

You can download all the packages, or just the commands you want. Add the directory you put them in to your path. Then the usual unix commands work (ls, grep, tail, etc.) work at the DOS prompt.

UncleO
Bash isn't included in this package.
MattFu
@MattFu Thanks for the comment. Bash isn't supposed to be included. GnuWin32 adds functionality to the DOS shell to make it act like bash. Just another alternative to cygwin.
UncleO
+4  A: 

Perhaps you could try Windows PowerShell. This solution is inspired by bash and has many advantages over it, including .NET support and the sole fact this is a native Microsoft solution.

All basic commands are present and you can easily configure your own aliases.

http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx

Ivan Suhinin