35

Running the command:

file run.sh

Gives me:

run.sh: Bourne shell script text executable

in Linux. Is there an equivalent command in Windows?

Gareth
  • 18,809
AabinGunz
  • 611
  • 5
    This is a QA forum. Not Google. You should try searching before just asking people here. - http://gnuwin32.sourceforge.net/packages/file.htm – Noufal Ibrahim Apr 18 '11 at 08:32
  • 16
    @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 - on strike Apr 18 '11 at 08:33
  • 2
    Cody: Arguably. I still think some research before firing off a question is a good thing. – Noufal Ibrahim Apr 18 '11 at 08:35
  • 8
    Sorry people, but i tried google and then I asked this question here. –  Apr 18 '11 at 08:39
  • @Noufal: gnuwin32.sourceforge.net/packages/file.htm link needs one to download a file, but instead I needed something that comes in every system, like the file command in Linux. Because when my application is complete it will be used by people an each system downloading the required file just for finding windows file bit size check is not feasible. I'll try more to look for some solution on google. Thanks :) –  Apr 18 '11 at 08:48
  • 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

9 Answers9

16

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>
Worthwelle
  • 4,648
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.

afrazier
  • 23,185
  • 1
    very nice. there is even an "online" scanner available that small files can be uploaded to. http://mark0.net/onlinetrid.aspx – user26398 Feb 11 '12 at 04:39
6

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).

  • 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 :) –  Apr 18 '11 at 09: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
  • Yeah, still works pretty good: > file.exe inkscape inkscape: symbolic link to /e/AppData/Roaming/inkscape. – Todd Partridge Mar 02 '24 at 18:07
2

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.

Gary
  • 756
  • As the majority of the world now uses Windows 10 I believe this answer should be accepted. –  Apr 07 '20 at 11:09
2

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

Edward
  • 123
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.

  • @nickgrim:,@skwllsp: I needed something that comes by default in every windows system. –  Apr 18 '11 at 08: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 :) –  Apr 18 '11 at 09:08
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.

Indigo
  • 1
0

If you have WSL installed, you can simply use the file command on Windows file system folder /mnt/.

Example:

file /mnt/c/"Program Files"/Notepad++/notepad++.exe

The output will be something similar to:

/mnt/c/Program Files/Notepad++/notepad++.exe: PE32+ executable (GUI) x86-64, for MS Windows

Rain
  • 101
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.