What is the equivalent to the Linux File command for windows?

16

2

Running the command:

file run.sh

Gives me:

run.sh: Bourne shell script text executable

in Linux. Is there an equivalent command in Windows?

AabinGunz

Posted 2011-04-18T08:23:58.940

Reputation: 411

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 – 2011-04-18T08:32:04.437

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 – 2011-04-18T08:33:18.080

2Cody: Arguably. I still think some research before firing off a question is a good thing. – Noufal Ibrahim – 2011-04-18T08:35:15.500

6Sorry people, but i tried google and then I asked this question here. – None – 2011-04-18T08:39:25.970

@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 :) – None – 2011-04-18T08:48:14.103

1The 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 – 2011-04-18T10:17:30.077

@NoufalIbrahim Thanks! the gnuwin32's file supported wildcards as well, which meant I could query all the files in a given directory. :-) – asgs – 2013-08-11T09:22:27.210

Answers

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

Jim Dennis

Posted 2011-04-18T08:23:58.940

Reputation: 404

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 – 2015-01-31T21:29:48.877

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 :) – None – 2011-04-18T09:05:22.227

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

Posted 2011-04-18T08:23:58.940

Reputation: 21 316

1

very nice. there is even an "online" scanner available that small files can be uploaded to. http://mark0.net/onlinetrid.aspx

– user26398 – 2012-02-11T04:39:08.233

3

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>

Green Bird

Posted 2011-04-18T08:23:58.940

Reputation: 31

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

Edward

Posted 2011-04-18T08:23:58.940

Reputation: 113

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

Posted 2011-04-18T08:23:58.940

Reputation:

@nickgrim:,@skwllsp: I needed something that comes by default in every windows system. – None – 2011-04-18T08:52:56.307

@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 :) – None – 2011-04-18T09:08:16.160

0

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

Posted 2011-04-18T08:23:58.940

Reputation: 646

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

Posted 2011-04-18T08:23:58.940

Reputation: 1

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.

user135362

Posted 2011-04-18T08:23:58.940

Reputation: