Bug 2053589 - RFE: add mode where file checks whether the file is of a specified type
Summary: RFE: add mode where file checks whether the file is of a specified type
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: file
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Vincent Mihalkovič
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-02-11 14:56 UTC by Zbigniew Jędrzejewski-Szmek
Modified: 2022-02-17 09:26 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Zbigniew Jędrzejewski-Szmek 2022-02-11 14:56:56 UTC
Description of problem:
It'd be great if file could be used to check if file matches a specific file output pattern.
Instead of doing 'file foo | grep -q "ELF"', you could do 'file --check="ELF" foo' and
file would return either 0 or 1 depending on whether it's identification matches.

That would allow file to be used to find files of a certain type, which
is occasionally needed and users ask about [1]:

  find -exec file --check="LSB pie executable" {} \;

would print all "LSB pie executable" matches. The argument would preferably be
an pcre regexp, or a glob pattern.

It would also be useful to do checks, e.g. 'file --check=stripped %{buildroot}/usr/bin/foo'.

[1] https://unix.stackexchange.com/questions/483871/how-to-find-files-by-file-type

Comment 1 Vincent Mihalkovič 2022-02-17 09:26:34 UTC
Interesting idea, I will try to implement this in (near) future.


Note You need to log in before you can comment on or make changes to this bug.