[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding Binary Files

From: David Martin
Subject: Re: Finding Binary Files
Date: Tue, 31 Oct 2000 11:12:53 -0600

Jon Wilson wrote:

> If you don't have or don't want Perl (why? :-0) then you could probably
> monkey up a shell script using the Unix 'file' command. Have a look at
> 'man file' to see exactly how your local version works, but you should be
> able to easily tell whether a file is one of 'text', 'executable' or
> 'data'.

In testing on a Sun Solaris 2.6 machine, I'd found that if the contents of the 
file command returns "text" or "script" as part of the return value, it is
*probably* an ASCII file; otherwise it is *probably* a binary file.  Your 
may vary!

e.g. check it from a perl script with the filename contained in $arg
$result = `/usr/bin/file $arg`;
if (( $result =~ /:.*text/ ) ||
( $result =~ /:.*script/ ) ) {
    # This is *probably* an ASCII file
    # This is *probably* a binary file


Attachment: f38796c.vcf
Description: Card for David Martin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]