'file' command: specifying search depth for 'search' option in /etc/magic file?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
ericmarceau
Level 1
Level 1
Posts: 7
Joined: Tue Nov 10, 2020 12:35 am

'file' command: specifying search depth for 'search' option in /etc/magic file?

Post by ericmarceau »

How can I specify how far/deep the 'file' command should search in a file to locate a match on a "search" definition ?

I am trying to create a universal specification in "/etc/magic" for multi-flavoured Prolog, so that I could do mass-transformation of imported predicate libraries for re-targeting to my personal environment for a project.

Having reviewed a number of the "target" files, I believe I would need to search within the first 3K characters of a file for this to be deemed reasonably successful as an approach.

So far I've tried these 2 flavours/definition, with no success:

Code: Select all

0	search/2048	[Pp][Rr][Oo][Ll][Oo][Gg]	Prolog Predicate File [ISO-Compliant Prolog], ASCII text 
and

Code: Select all

0	search	[Pp][Rr][Oo][Ll][Oo][Gg]	Prolog Predicate File [ISO-Compliant Prolog], ASCII text 
This second one is successful but only if the pattern is found in the first line of the file.

I have also defined this initial set of other specifications to normalize the files which will be massaged to conform:

Code: Select all

0	string	%%Prolog	Prolog Predicate File [Non-Specific], ASCII text 
0	string	%%gprolog	Prolog Predicate File [GNU Prolog], ASCII text 
0	string	%%swipl		Prolog Predicate File [SWI-Prolog], ASCII text 
0	string	%%yap		Prolog Predicate File [YAP Prolog], ASCII text 
0	string	%%eclipse	Prolog Predicate File [ECLiPSe], ASCII text 
0	string	%%bprolog	Prolog Predicate File [B-Prolog], ASCII text 
0	string	%%poplog	Prolog Predicate File [Poplog], ASCII text 
0	string	%%lpaprolog	Prolog Predicate File [LPA Prolog], ASCII text 
0	string	%%isoprolog	Prolog Predicate File [ISO-Compliant Prolog], ASCII text 
I have created this last definition so that I may specifically tag those predicate files which I have confirmed as compliant with ISO Prolog specifications.

I do NOT want to use the "shebang" (i.e. #!/bin/gprolog) notation for first line auto-detection for execution.

Guidance on search depth specification would be greatly appreciated.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Locked

Return to “Installation & Boot”