Purpose: | Search files for the specified text |
Format: | FSEARCH [/= /+n /-n /8 /B /C /E"regex" /F /G /H /I /L /N[dehjs] /Q /S[[+]n] /T"text" /U /V /Y /Z] [path] filename |
Usage:
FSEARCH is a modern replacement for the aged FFIND. New features will only be implemented in FSEARCH, not FFIND.
FSEARCH will automatically determine the file type (ASCII, UTF8, or UTF16). You can also tell FSEARCH to assume UTF8 files with the /8 option. (This is slightly faster because FSEARCH doesn't have to pre-scan the files trying to determine the encoding.)
You can use TCC extended wildcards in the search string. For example, the following command will find .TXT files which contain either the string June or July. It will also find Juny and Jule. The /C option makes the search case-sensitive:
fsearch /c /t"Ju[nl][ey]" *.txt
You can also search using regular expressions using the /E option. See Regular Expression Syntax for supported expressions.
When you use FSEARCH on an LFN drive, you must quote any file names which contain white space or special characters.
FSEARCH sets three internal variables:
_fsearch_errors - Errors when running FSEARCH (i.e., file/path not found, file locked, access denied, etc.)
_fsearch_files - The number of files containing one or more matches
_fsearch_matches - The total number of matches
Options:
/= | Display the FSEARCH dialog |
/+n | Skip the first n matches |
/-n | Stop after n matches |
/8 | Instead of scanning the files for their type, they are assumed to be UTF8 (this is a little faster). |
/B | Only display filenames (no header or footer or summary or matching lines) |
/C | Match case |
/E"..." | Regular expression search |
/F | Stop after first match (overrides /V) |
/G | Change to the directory containing the first matching file (also sets /F and overrides /V) |
/H | Don't search for text in binary files. By default, this includes .exe, .dll, .sys, .chm, .zip, .pdb, .pch, .obj, .tar, .com, and .ewriter. You can define your own list by setting the "BINARY_FILES" environment variable. |
For example, to ignore .exe, .sys, and .dll files:
BINARY_FILES=.exe;.sys;.dll
/I | Used with /T to tell FSEARCH to ignore wildcard characters (*, ?, and [...]). |
/L | Display line numbers for matching text |
/N... | Disable options: |
D | Don't scan hidden subdirectories |
E | Don't display errors |
H | No header |
J | Skip junctions |
S | No footer (summary) |
/Q | Don't display any output. The internal variables (see below - _fsearch_errors, _fsearch_files, and _fsearch_matches are set). |
/S | Search subdirectories of the specified (or default) path. |
If you specify a number following the /S, FFIND will limit the subdirectory recursion to the number specified. For example, if you have a directory tree "\a\b\c\d\e", /S2 will only go to the "a", "b", and "c" directories.
If you specify a + followed by a number after the /S, FFIND will not search for files until it gets to that depth in the subdirectory tree. For example, if you have a directory tree \a\b\c\d\e, /S+2 will not find anything in \a or \a\b.
/T"..." | Search for the matching text. Supports TCC wildcards (?, *, and [...]). |
/U | Only display summary line (no filenames or matching lines; overrides /V) |
/V | Display all matching text (FFIND defaults to only displaying the first match in each file) |
/Y | Display a "Continue Y/N" prompt after displaying each match |
/Z | Highlight the matched text |