Difference between revisions of "Find"

From wiki.amiga.org
Jump to navigation Jump to search
Line 304: Line 304:
  
 
<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.
 +
  
  

Revision as of 15:06, 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.