[SATLUG] checking for data file type and deleting
(metadata search?)
Luis Garza
luis at luisgarza.com
Fri Jun 1 15:01:51 CDT 2007
Jonathan Hull wrote:
> 'file'?
>
>> file somefile.exe
>
>
> On 6/1/07, twistedpickles <twistedpickles at gmail.com> wrote:
>>
>> I run this regexp to remove windows executable files from a linux
>> directory server:
>>
>> find dir -name *.exe -ok rm '{}' \;
>>
>> I would like to learn how to scan for the file types. For example if a
>> user changes the extension from exe to doc is there a way to figure
>> out if it is an executable and then delete.
I believe that file looks at the i-node information and not the actual
file its self.
You may need to write a perl script that looks at the file contents
either with 'file' or the magic file /usr/share/file/magic
I'm pretty sure,though I don't know of one, that CPAN has a PM that
looks at the files contents; like take the first 10 characters and
compare it to the magic file.
Its been a while since I have used perl, but it is pretty powerful.
--
Luis Garza
luis at luisgarza.com
l.garza at yahoo.com
More information about the SATLUG
mailing list