Difference between revisions of "Find"

From wiki.amiga.org
Jump to navigation Jump to search
 
(29 intermediate revisions by the same user not shown)
Line 46: Line 46:
  
 
'''DIR'''
 
'''DIR'''
 +
 
Path(s) to include in the search.
 
Path(s) to include in the search.
  
  
'''DLEVEL''' <int>
+
'''DLEVEL''' <span style="font-family:Courier;"><int></span>
 +
 
 
Sets directory depth level:
 
Sets directory depth level:
  
Line 57: Line 59:
  
  
'''NAME''' <name/pattern>
+
'''NAME''' <span style="font-family:Courier;"><name/pattern></span>
 +
 
 
Search for files that match a given name or pattern.
 
Search for files that match a given name or pattern.
  
Line 66: Line 69:
 
</pre>
 
</pre>
 
   
 
   
'''CONTENTS''' <string>
+
 
 +
'''CONTENTS''' <span style="font-family:Courier;"><string></span>
 +
 
 
Search in file contents for a given string.
 
Search in file contents for a given string.
  
Line 72: Line 77:
 
                    
 
                    
 
    
 
    
Operator syntax                 Description                              Example
+
{| class="wikitable"|
----------------                 ------------                             --------
+
|-
 +
!style="width: 20%"|<u>Operator Syntax</u>                  
 +
!<u>Description</u>                                
 +
!<u>Example</u>
 +
|-
 +
|<b>\:</b> <span style="font-family:Courier;"><string></span>               
 +
|string to match or search for
 +
|"\:simple search\;" : find string anywhere in the file
 +
|-
 +
|<b>\;</b>       
 +
|search statement terminator
 +
|"\:string1\;\:string2\;" : find these strings in any order
 +
|-
 +
|<b>\x</b> <span style="font-family:Courier;"><hex byte value></span>
 +
|hex byte value inside match string
 +
|"\:string to find\x0A\x00\;" : find a string terminated with 0x0A and 0x00
 +
|-
 +
|<b>\c</b>     
 +
|match must be case-sensitive
 +
|"\:MustMatchCase\c\;" : find this string with case-sensitivity
 +
|-
 +
|<b>\></b> <span style="font-family:Courier;"><signed decimal value></span>
 +
|file location to start search
 +
|"\>64\:string1\;" : start searching for "string1" 64 bytes from the start of file.
 +
"\>-100\:string1\;" : start searching for "string1" 100 bytes from the end of file.
 +
|-
 +
|<b>\<</b> <span style="font-family:Courier;"><signed decimal value></span>
 +
|file location to end search
 +
|"\>64\<120\:string1\;" : search for "string1" from byte 64 to byte 120 of a file.
 +
"\>-150\<-80\:string1\;" : search for "string1" starting at 150 bytes from the end and ending 80 bytes from the end of file.
 +
|-
 +
|<b>\@</b> <span style="font-family:Courier;"><signed decimal value></span>
 +
|match string at specific file location
 +
|"\@0\:\x00\x00\x03\xF3\;" : match executable file header
 +
"\@-64\:something\;" : match "something" 64 bytes from the end of file
 +
|-
 +
|<b>\[</b> <span style="font-family:Courier;"><signed decimal value></span>
 +
|match string at offset relative to start of last match
 +
|"\:string1\;\[20\:string2\;" : search for "string1" and match "string2" 20 bytes AFTER the FIRST char of "string1".
 +
"\:string1\;\[-12\:string2\;" : search for "string1" and match "string2" 12 bytes BEFORE the FIRST char of "string1".
 +
|-
 +
|<b>\]</b> <span style="font-family:Courier;"><signed decimal value></span>
 +
|match string at offset relative to end of last match.
 +
|"\:string1\;\]22\:string2\;" : search for "string1" and match "string2" 22 bytes AFTER the LAST char of "string1".
 +
"\:string1\;\]-30\:string2\;" : search for "string1" and match "string2" 30 bytes BEFORE the LAST char of "string1".
 +
|-
 +
|<b>\#</b> <span style="font-family:Courier;"><signed decimal value></span>
 +
|search for string starting at offset relative to last match.
 +
|"\:string1\;\#48\:string2\;" : search for "string1" and then for "string2" 48 bytes AFTER the LAST char of "string1".
 +
"\:string1\;\#-60\:string2\;" : search for "string1" and then for "string2" 60 bytes BEFORE the FIRST char or "string1".
 +
|-
 +
|<b>\!</b> <span style="font-family:Courier;"><hex byte value(s)></span>   
 +
|end a search when a character with the given value(s) is found.
 +
Up to 8 comma-separated byte hex values can be given and also a value range in the form: <start value>-<end value> or <start value>- or -<end value>.   
 +
|"\:$VER:\c\;\#0\!00,0A,0D,80-\:string\;"  : search for "string" in a file's version string. The search ends when a null (00) or line feed (0A) or carriage return (0D) or a character code over 80 hex is foundz
 +
|}
  
\: <string>               :     string to match or search for            "\:simple search\;" : find string anywhere in the file
+
<u>Note</u>: Difference between "search" and  "match": "Match" means to find a string at a specific file location, while "Search" means to find a string anywhere within the specified range of file data.
  
\;                         :    search statement terminator              "\:string1\;\:string2\;" : find these strings in any order
+
&nbsp;
 
 
\x <hex byte value>        :    hex byte value inside match string        "\:string to find\x0A\x00\;" : find a string terminated with 0x0A and 0x00
 
 
 
\c                        :    match must be case-sensitive              "\:MustMatchCase\c\;" : find this string with case-sensitivity
 
 
 
\> <signed decimal value>  :    file location to start search            "\>64\:string1\;" : start searching for "string1" 64 bytes from the start
 
                                                                                              of file.
 
 
 
                                                                          "\>-100\:string1\;" : start searching for "string1" 100 bytes from the
 
                                                                                                end of file.
 
 
 
\< <signed decimal value>  :    file location to end search              "\>64\<120\:string1\;" : search for "string1" from byte 64 to byte 120
 
                                                                                                    of a file.
 
 
 
                                                                          "\>-150\<-80\:string1\;" : search for "string1" starting at 150 bytes from
 
                                                                                                      the end and ending 80 bytes from the end of file.
 
 
 
\@ <signed decimal value>  :    match string at specific file location    "\@0\:\x00\x00\x03\xF3\;" : match executable file header
 
 
 
                                                                          "\@-64\:something\;" : match "something" 64 bytes from the end of file
 
 
 
\[ <signed decimal value>  :    match string at offset relative to        "\:string1\;\[20\:string2\;" : search for "string1" and match "string2"
 
                                start of last match.                                                    20 bytes AFTER the FIRST char of "string1".
 
                                                                         
 
                                                                          "\:string1\;\[-12\:string2\;" : search for "string1" and match "string2"
 
                                                                                                          12 bytes BEFORE the FIRST char of "string1".
 
 
 
\] <signed decimal value>  :    match string at offset relative to        "\:string1\;\]22\:string2\;" : search for "string1" and match "string2"
 
                                end of last match.                                                      22 bytes AFTER the LAST char of "string1".
 
 
 
                                                                          "\:string1\;\]-30\:string2\;" : search for "string1" and match "string2"
 
                                                                                                          30 bytes BEFORE the LAST char of "string1".
 
 
 
\# <signed decimal value>  :    search for string starting at offset      "\:string1\;\#48\:string2\;" : search for "string1" and then for "string2"
 
                                relative to last match.                                                  48 bytes AFTER the LAST char of "string1".
 
 
 
                                                                          "\:string1\;\#-60\:string2\;" : search for "string1" and then for "string2"
 
                                                                                                          60 bytes BEFORE the FIRST char or "string1".
 
 
 
\! <hex byte value(s)>    :    end a search when a character with        "\:$VER:\c\;\#0\!00,0A,0D,  : search for "string" in a file's version
 
                                the given value(s) is found.              80-\:string\;"                string. The search ends when a null (00) or
 
                                Up to 8 comma-separated byte hex values                                  line feed (0A) or carriage return (0D)
 
                                can be given and also a value range                                      or a character code over 80 hex is found.
 
                                in the form: <start value>-<end value>
 
                                or <start value>- or -<end value>.
 
 
 
''''Note'''': Difference between "search" and  "match": "Match" means to find a string at a specific file location, while "Search" means to find a string anywhere within the specified range of file data.
 
  
 
Examples of CONTENTS operator usage:
 
Examples of CONTENTS operator usage:
Line 189: Line 202:
  
  
'''MAXSIZE''' <byte size>
+
'''MAXSIZE''' <span style="font-family:Courier;"><byte size></span>
  
 
Match files that are up to <byte size> in size.  
 
Match files that are up to <byte size> in size.  
Line 195: Line 208:
 
Example:
 
Example:
  
MAXSIZE 65536 : Match files up to 64 KB in size.
+
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
 +
MAXSIZE 65536  
 +
</pre>
 +
 
 +
Match files up to 64 KB in size.
  
  
  
'''MINSIZE''' <byte size>
+
'''MINSIZE''' <span style="font-family:Courier;"><byte size></span>
  
 
Match files hat are at least <byte size> in size.
 
Match files hat are at least <byte size> in size.
Line 205: Line 222:
 
Example:
 
Example:
  
MINSIZE 2048 : Match files at least 2 KB in size.
+
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
 +
MINSIZE 2048  
 +
</pre>
 +
 
 +
Match files at least 2 KB in size.
  
  
  
'''WITHIN''' <int>m/h/d
+
'''WITHIN''' <span style="font-family:Courier;"><int>m/h/d</span>
  
 
Match files with a date within <int> minutes or hours or days from now.
 
Match files with a date within <int> minutes or hours or days from now.
Line 215: Line 236:
 
Examples:
 
Examples:
  
WITHIN 120m : Match files created/modified within the last 2 hours.
+
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
 +
WITHIN 120m  
 +
</pre>
 +
 
 +
Match files created/modified within the last 2 hours.
 +
 
 +
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
 +
WITHIN 36h
 +
</pre>
 +
 
 +
Match files created/modified within the last 36 hours.
  
WITHIN 36h : Match files created/modified within the last 36 hours.
+
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
 +
WITHIN 60d
 +
</pre>
  
WITHIN 60d : Match files created/modified within the last 2 months.
+
Match files created/modified within the last 2 months.
  
  
  
'''BETWEEN''' <date1, date2>
+
'''BETWEEN''' <span style="font-family:Courier;"><date1, date2></span>
  
 
Match files with a date between date1 and date2.
 
Match files with a date between date1 and date2.
Line 236: Line 269:
  
  
'''COMMENT''' <string/pattern>
+
'''COMMENT''' <span style="font-family:Courier;"><string/pattern></span>
  
 
Match files with a comment that matches the given string of pattern.
 
Match files with a comment that matches the given string of pattern.
Line 249: Line 282:
  
  
'''PROT''' <hsparwed protection bits>
+
'''PROT''' <span style="font-family:Courier;"><hsparwed protection bits></span>
  
 
Match files with the given protection bits.
 
Match files with the given protection bits.
Line 257: Line 290:
 
Examples:
 
Examples:
  
PROT pe : Match files with the 'pure' and 'execute' protection bits set. All other protection bits will be ignored.
+
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
PROT -srwed : Match files that have the 'script' bit off and 'read', 'write', 'execute' and 'delete' bits on.
+
PROT pe  
 +
</pre>
 +
Match files with the 'pure' and 'execute' protection bits set. All other protection bits will be ignored.
 +
 
 +
 
 +
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
 +
PROT -srwed  
 +
</pre>
 +
Match files that have the 'script' bit off and 'read', 'write', 'execute' and 'delete' bits on.
  
  
Line 274: Line 315:
  
 
'''CASECOMMENT'''
 
'''CASECOMMENT'''
 +
 
Force comment comparison with the COMMENT option to be case-sensitive.
 
Force comment comparison with the COMMENT option to be case-sensitive.
  
Line 284: Line 326:
  
 
'''CASECONTENTS'''
 
'''CASECONTENTS'''
 +
 
Force string comparison with the CONTENTS option to be case-sensitive for all given search strings.
 
Force string comparison with the CONTENTS option to be case-sensitive for all given search strings.
  
Line 289: Line 332:
  
 
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
 
<pre style="color: black; background:lightgray; font-family:courier; width:60%">
CONTENTS "\:myFunc1\;\:myFunc2\;" CASECONTENTS : search for "myFunc1" and "myFunc2" with case sensitivity.
+
CONTENTS "\:myFunc1\;\:myFunc2\;" CASECONTENTS
 
</pre>
 
</pre>
 +
 +
Search for "myFunc1" and "myFunc2" with case sensitivity.
 +
  
  
 
'''FOLLOWLINKS'''
 
'''FOLLOWLINKS'''
 +
 
Also enter and search soft or hard directory links. The true path of matched files will also be shown after the path of the directory link. The default behaviour is not to enter directory links.
 
Also enter and search soft or hard directory links. The true path of matched files will also be shown after the path of the directory link. The default behaviour is not to enter directory links.
  
Line 308: Line 355:
  
  
'''LFORMAT''' <formatting string>
+
'''LFORMAT''' <span style="font-family:Courier;"><formatting string></span>
 +
 
 
Change the default output for found files.
 
Change the default output for found files.
 
   
 
   
Line 333: Line 381:
  
 
'''NOSIZES'''
 
'''NOSIZES'''
 +
 
Do not show file size of files found. Also prevents protection info from being shown.
 
Do not show file size of files found. Also prevents protection info from being shown.
  
Line 338: Line 387:
  
 
'''NODATES'''
 
'''NODATES'''
 +
 
Do not show date and time of files found. Also prevents protection info from being shown.
 
Do not show date and time of files found. Also prevents protection info from being shown.
  
Line 343: Line 393:
  
 
'''NOMULTI'''
 
'''NOMULTI'''
 +
 
Do not search in multi-assign directories.
 
Do not search in multi-assign directories.
  
Line 348: Line 399:
  
 
'''NOICONS'''
 
'''NOICONS'''
 +
 
Do not include icon files (.info) in the results of files found.
 
Do not include icon files (.info) in the results of files found.
  
Line 353: Line 405:
  
 
'''PLAIN'''
 
'''PLAIN'''
 +
 
Show only a plain filename list for the results without formatting line feeds or any additional statistics.
 
Show only a plain filename list for the results without formatting line feeds or any additional statistics.
  
 
&nbsp;
 
&nbsp;
 
  
 
&nbsp;
 
&nbsp;
Line 362: Line 414:
 
=Copyright=
 
=Copyright=
 
&nbsp;
 
&nbsp;
Copyright (C) 2022 AmigaKit Ltd.  Distributed with the Enhancer Software under licence.
+
Copyright (C) 2023 AmigaKit Ltd.  Distributed with the Enhancer Software under licence.

Latest revision as of 19:31, 26 February 2023

   

Description

The Find command searches through files and directories to locate file(s) matching the search keyword.

 

Installation

Commands Icon.jpg
The Find command file is installed in the SYS:C/ directory by default.

 

Versions

  Latest versions are 46.0 and 54.0

Updater Icon.png
Use the Updater utility to upgrade to and install the latest available version.


   

Command Line Usage

   

DIR/M,DLEVEL/N,NAME/K,CONTENTS/K,MAXSIZE/K/N,MINSIZE/K/N,WITHIN/K,BETWEEN/K,COMMENT/K,PROT/K,CASENAME/S,CASECOMMENT/S,CASECONTENTS/S,FOLLOWLINKS/S,LFORMAT/K,NOSIZES/S,NODATES/S,NOMULTI/S,NOICONS/S,PLAIN/S

   


DIR

Path(s) to include in the search.


DLEVEL <int>

Sets directory depth level:

0 : only root directory is searched - no directories are entered 1 : only root and directories in root are searched 2 : root + 2 directory levels are searched, and so on...


NAME <name/pattern>

Search for files that match a given name or pattern.

Example:

NAME #?.guide : Match files that have a ".guide" filename suffix.


CONTENTS <string>

Search in file contents for a given string.

For simple searches only the string to search for may be given. For more complex searches several operators can also be used inside the string to enable multi-string searches, mixing hex byte codes with strings, case-sensitive matches, setting search boundaries and other things.


Operator Syntax Description Example
\: <string> string to match or search for "\:simple search\;" : find string anywhere in the file
\; search statement terminator "\:string1\;\:string2\;" : find these strings in any order
\x <hex byte value> hex byte value inside match string "\:string to find\x0A\x00\;" : find a string terminated with 0x0A and 0x00
\c match must be case-sensitive "\:MustMatchCase\c\;" : find this string with case-sensitivity
\> <signed decimal value> file location to start search "\>64\:string1\;" : start searching for "string1" 64 bytes from the start of file.

"\>-100\:string1\;" : start searching for "string1" 100 bytes from the end of file.

\< <signed decimal value> file location to end search "\>64\<120\:string1\;" : search for "string1" from byte 64 to byte 120 of a file.

"\>-150\<-80\:string1\;" : search for "string1" starting at 150 bytes from the end and ending 80 bytes from the end of file.

\@ <signed decimal value> match string at specific file location "\@0\:\x00\x00\x03\xF3\;" : match executable file header

"\@-64\:something\;" : match "something" 64 bytes from the end of file

\[ <signed decimal value> match string at offset relative to start of last match "\:string1\;\[20\:string2\;" : search for "string1" and match "string2" 20 bytes AFTER the FIRST char of "string1".

"\:string1\;\[-12\:string2\;" : search for "string1" and match "string2" 12 bytes BEFORE the FIRST char of "string1".

\] <signed decimal value> match string at offset relative to end of last match. "\:string1\;\]22\:string2\;" : search for "string1" and match "string2" 22 bytes AFTER the LAST char of "string1".

"\:string1\;\]-30\:string2\;" : search for "string1" and match "string2" 30 bytes BEFORE the LAST char of "string1".

\# <signed decimal value> search for string starting at offset relative to last match. "\:string1\;\#48\:string2\;" : search for "string1" and then for "string2" 48 bytes AFTER the LAST char of "string1".

"\:string1\;\#-60\:string2\;" : search for "string1" and then for "string2" 60 bytes BEFORE the FIRST char or "string1".

\! <hex byte value(s)> end a search when a character with the given value(s) is found.

Up to 8 comma-separated byte hex values can be given and also a value range in the form: <start value>-<end value> or <start value>- or -<end value>.

"\:$VER:\c\;\#0\!00,0A,0D,80-\:string\;" : search for "string" in a file's version string. The search ends when a null (00) or line feed (0A) or carriage return (0D) or a character code over 80 hex is foundz

Note: Difference between "search" and "match": "Match" means to find a string at a specific file location, while "Search" means to find a string anywhere within the specified range of file data.

 

Examples of CONTENTS operator usage:

Find 68K executables:

"\@0\:\x00\x00\x03\xF3\c\;"

Find PPC executables:

"\@0\:\x7F\x45\x4C\x46\c\;"

Find PNG images:

"\@0\:\x89PNG\c\;"

Find IFF ILBM images:

"\@0\:FORM\c\;\@8\:ILBM\c\;"

Find IFF PREFS files:

"\@0\:FORM\c\;\@8\:PREF\c\;"

Find IFF sound files:

"\@0\:FORM\c\;\@8\:8SVX\c\;"

Find WAV sound files:

"\@0\:RIFF\c\;\@8\:WAVE\c\;"

Find JPEG JFIF images:

"\@0\:\xFF\xD8\xFF\xE0\c\;\@6\:JFIF\x00\c\";

Find in version string (case-insensitive):

"\:$VER:\c\;\#0\!00,0A,0D,80-\:string to find\;"

Find in version string (case-sensitive):

"\:$VER:\c\;\#0\!00,0A,0D,80-\:string to find\c\;"


MAXSIZE <byte size>

Match files that are up to <byte size> in size.

Example:

MAXSIZE 65536 

Match files up to 64 KB in size.


MINSIZE <byte size>

Match files hat are at least <byte size> in size.

Example:

MINSIZE 2048 

Match files at least 2 KB in size.


WITHIN <int>m/h/d

Match files with a date within <int> minutes or hours or days from now.

Examples:

WITHIN 120m 

Match files created/modified within the last 2 hours.

WITHIN 36h 

Match files created/modified within the last 36 hours.

WITHIN 60d 

Match files created/modified within the last 2 months.


BETWEEN <date1, date2>

Match files with a date between date1 and date2.

Accepted date formats are whatever the locale default is and DOS date format (dd-mmm-yy).

Examples:

BETWEEN 18-Dec-22,1-Feb-23 : Match files created/modified between 18 December 2022 and 1 February 2023


COMMENT <string/pattern>

Match files with a comment that matches the given string of pattern.

Examples:

COMMENT "written by me" : Match files with "written by me" as a comment.

COMMENT "written by#?" : Match files with comments that start with "written by".


PROT <hsparwed protection bits>

Match files with the given protection bits.

Protection bits that are prefixed with a minus '-' sign should off to have a match.

Examples:

PROT pe 

Match files with the 'pure' and 'execute' protection bits set. All other protection bits will be ignored.


PROT -srwed 

Match files that have the 'script' bit off and 'read', 'write', 'execute' and 'delete' bits on.


CASENAME

Force name comparison with the NAME option to be case-sensitive.

Example:

NAME "#?.library" CASENAME


CASECOMMENT

Force comment comparison with the COMMENT option to be case-sensitive.

Example:

COMMENT "#?written by#?" CASECOMMENT


CASECONTENTS

Force string comparison with the CONTENTS option to be case-sensitive for all given search strings.

Example:

CONTENTS "\:myFunc1\;\:myFunc2\;" CASECONTENTS

Search for "myFunc1" and "myFunc2" with case sensitivity.


FOLLOWLINKS

Also enter and search soft or hard directory links. The true path of matched files will also be shown after the path of the directory link. The default behaviour is not to enter directory links.

Example:

Find FFS:hlinkdirtest NAME al#? FOLLOWLINKS

Searching in "FFS:hlinkdirtest" ...
AllFramesOff                       144 ----rwed 02/11/21 14:00 FFS:hlinkdirtest/ 
All.small                         1628 ----rwed 09/05/13 08:19 FFS:hlinkdirtest/dir1/ > FFS:hlinkdirtarget_orig/Dopus5/Images/ 
All                                484 ----rwed 03/11/99 22:28 FFS:hlinkdirtest/dir1/ > FFS:hlinkdirtarget_orig/Dopus5/Images/ 


LFORMAT <formatting string>

Change the default output for found files.

The default formatting string is: "%-30n %7l %a %d %t %f %c"

Available operators are:
%a : protection
%b : block size
%c : comment
%d : date
%e : filename extension
%f : full file path
%k : disk key
%l : byte size
%m : filename without extension
%n : filename
%r : link target
%t : time
%v : group protection
%u : owner user ID
%g : group user ID           


NOSIZES

Do not show file size of files found. Also prevents protection info from being shown.


NODATES

Do not show date and time of files found. Also prevents protection info from being shown.


NOMULTI

Do not search in multi-assign directories.


NOICONS

Do not include icon files (.info) in the results of files found.


PLAIN

Show only a plain filename list for the results without formatting line feeds or any additional statistics.

 

 

Copyright

  Copyright (C) 2023 AmigaKit Ltd. Distributed with the Enhancer Software under licence.