Re: identify the file type

From: Brett Viren <bv_at_bnl.gov>
Date: Mon, 23 May 2011 11:46:01 -0400


Adrian Sevcenco <Adrian.Sevcenco_at_cern.ch> writes:

> Hi! Is there a way to identify the file type other than using a bash
> command like:
> file -b $file | awk '{print $1}'
>
> I want to distinguish between XML and ASCII file types.

The "file" command is a CLI to libmagic. I've never used it personally but you should be able to link your code against it and use the functions defined in magic.h. Some sparse documentation is in the libmagic(3) man page.

-Brett.

Received on Mon May 23 2011 - 17:46:07 CEST

This archive was generated by hypermail 2.2.0 : Mon May 23 2011 - 23:50:02 CEST