On Sat, 11 Oct 2003, Andrew Gaffney wrote:

> Good. Thanks. Additionally, what I want to do is add a flag you can pass
> to this script that will tell it to scan only binaries or all files. Is
> there a quick way to determine whether a file is a binary or not? I was
> thinking about using the 'file' command.

File and stat can tell if a file is executable, text, binary, etc.  Of
course, being binary doesn't mean it is executable, and vice versa.  Also
see the 'test' command.  'if [ -x file ]' will tell you if file is
executable (though that could also include a directory).  Watch your
spaces on that - [ is a command, and ] is an ending delimiter for that.
If you miss a space, it's wrong.

If you write your script in Perl (or, I also assume, in Python), then it
may become easier to get the specific information about the file that you
want.

> Which takes more time: 'file' or generating an MD5SUM? I'm trying to
> determine whether to use 'file' to determine which files are binaries
> and then checking MD5SUM's on those, or checking MD5SUM's on all files
> and only use 'file' on ones that don't match the MD5SUM to determine if
> its worth reporting.

File is much faster.  It only checks the very beginning of the file.
md5sum needs to read the entire file in order to be able to add up the
contents and come up with a checksum.  Use file and md5sum on an iso and
it's very clear which is faster.

-- 
Marshal Newrock, unemployed Linux user in Lansing, MI
Caution: Product will be hot after heating


--
[EMAIL PROTECTED] mailing list

Reply via email to