19

Running the command:

file run.sh

Gives me:

run.sh: Bourne shell script text executable

in Linux. Is there an equivalent command in Windows?

  • 5
    This is a QA forum. Not Google. You should try searching before just asking people here. - gnuwin32.sourceforge.net/packages/file.htm – Noufal Ibrahim Apr 18 '11 at 8:32
  • 10
    @Noufal: No, you shouldn't. Q&A means that you ask questions. This is a question. Q&A doesn't imply anything about searching first. – Cody Gray Apr 18 '11 at 8:33
  • 2
    Cody: Arguably. I still think some research before firing off a question is a good thing. – Noufal Ibrahim Apr 18 '11 at 8:35
  • 6
    Sorry people, but i tried google and then I asked this question here. – Abhishek Simon Apr 18 '11 at 8:39
  • 1
    The file command is not part of the Linux kernel per say. It's a package that's installed on most distributions by default. Windows doesn't have something like this. Most decisions there are taken based on file extensions rather that content. – Noufal Ibrahim Apr 18 '11 at 10:17
4

There probably isn't one on your system by default. You could install the Cygwin tools suite (ports of GNU commands to the Win32 APIs). There used to also be the MKS Toolkit and another one whose name escapes me at the moment. MKS was commercial, Cygwin, of course was GNU/GPL, and the other won was eventually renamed (from OpenNT?) and later acquired by Microsoft and incorporated into some sort of MSDN suite for Win2K or Server 2003 or something like that.

For any of those you'd just run the 'file' command on your target files just as you would under UNIX. You might have to start them under the included UNIX-like shell (bash, for Cygwin, ksh or MKS Toolkit, and who knows what for the other one).

| improve this answer | |
  • Hey thanks for the info, I heard about MKS too and worked on Cygwin, but then again I was wondering whether there is a tool that comes by default in windows. Thanks anyways :) – Abhishek Simon Apr 18 '11 at 9:05
  • I downloaded cygwin and then was able to copy the cygwin install directory to the system I wanted to run the file command on and was then able to call the file.exe command underneath the copied cygwin directory without "installing" cygwin on the target system. – Chris Magnuson Jan 31 '15 at 21:29
7

As others have said, there's nothing built into Windows. If you'd like an alternative to the file ports, check out TrID. The developer also makes the analyzer available as both a Win32 DLL or a .NET Assembly.

| improve this answer | |
6

1. You can download and install git for Windows

It has a built-in file command in git-bash.exe

2. You can use Windows build of file

Link here https://github.com/nscaife/file-windows/releases

Or here https://github.com/julian-r/file-windows/releases

3. Try https://github.com/joeky888/fil

It is a command tool written in Go.

Similar to file command but cross-platform without any dependency.

Usage:

file <SOME_FILE>
| improve this answer | |
  • +1 for git-bash.exe. – djhurio Jun 8 at 14:09
1

Not built-in; Windows uses file-extensions to determine file-type. I'm pretty sure that there's a port of file in Cygwin, though.

| improve this answer | |
  • @nickgrim:,@skwllsp: I needed something that comes by default in every windows system. – Abhishek Simon Apr 18 '11 at 8:52
  • @nickgrim: This might be it, because windows uses file-extensions to determine file-type, so there is no built it command. If I happen to find a solution i'll post it here. Thanks all for your efforts :) – Abhishek Simon Apr 18 '11 at 9:08
1

On Windows 10, you can now install Bash. Once that's installed, you'll have access to the same File command that Ubuntu uses. It might be a bit overkill to do all this just for the one command, but I find it quite useful.

| improve this answer | |
  • As the majority of the world now uses Windows 10 I believe this answer should be accepted. – user1100970 Apr 7 at 11:09
1

If you want the file command without installing all of Cygwin, you can pick up a copy from the GnuWin project. It's an older build but still useful:

http://gnuwin32.sourceforge.net/packages/file.htm

| improve this answer | |
0

Take a look at File.exe - a small program similar to the Unix / Linux file executable which can examine files, in this case it is designed to query an executable file and display the processor that the file was compiled to run on and any other details it can report on.

| improve this answer | |
0

Try getting a copy of cmder.exe you can run without installing and it has nix commands built in. You can also add any additional commands you might want that will load into path on launch.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.