C:\Documents and Settings\Administrator>
#f
===============================================================================
find Ver 2.3.3.0119 by BaiYang / 2004 - 2012, Freeware
http://baiy.cn
===============================================================================
Find string in file(s)
USAGE: f [filePattern1 filePattern2 ...] <findOption>:<find> [otherOptions]
===============================================================================
FIND OPTION:
-f: - find
-fic: - find ignore case
-r: - regular expresion find
-ric: - regular expresion find ignore case
-rnnl: - regular expresion find no newline
-rnnlic: - regular expresion find no newline and ignore case
-l:nnn-mmm - find contents from line 'nnn' to 'mmm', if 'mmm' is omited, all
contents from line 'nnn' will be matched.
===============================================================================
OTHER OPTION:
-s - include sub dirs
-stdin - use standard input device (keyboard or pipe) instead of files
default if no file pattern is given
-o: - output format, key word is:
f filename - relatively path
F filename - absolutely path
o line offset
x line offset (hex)
s matched string's char size
S matched string's byte size
O file offset
X file offset (hex)
b line offset by bytes
B file offset by bytes
l line number
c line content
C the file content (CAUTION: maybe very large)
k whole matched content blocK. (maybe multi lines.)
t table
r return
n new line
DEFAULT:'f:l:c'with normal mode; 'c' on stdin and 'k' on line mode
-of: - only list the matching file(s), this options overwrite the "-o:"
option. this option's key word can only be:
f filename - relatively path
F filename - absolutely path
DEFAULT: f (if "-of" has specified with no value).
-co - apply compact output: only show the first match if more then one
matchs are found in the same line.
-fmc - Show File Match Count (match count of per file)
-tmc - Show Total Match Count
-format: - file format, can be "auto" "dos", "unix" or "mac"
DEFAULT: auto
-unicode - tell find parsing the input as an unicode (utf-16) file.
DEFAULT: deal input files as ANSI/MBCS encoding
-errstop - stop on a file or sub-directory access error (the old behave).
DEFAULT: ignore the access error and try to continue.
===============================================================================
POSIX and perl style Regular Expression:
- "find" fully support POSIX.2 Extended and Perl style Regular Expresion.
Here is a list of they character classes:
POSIX perl Description
--------------------------------------------------------------------
[:alnum:] letters and digits
[:alpha:] \a letters
[:lower:] \l lowercase letters
[:upper:] \u uppercase letters
[:blank:] space and tab characters
[:space:] \s whitespace characters
[:cntrl:] control characters
[:digit:] \d decimal digits
[:xdigit:] \x hexadecimal digits
[:graph:] printable characters excluding space
[:print:] \p printable characters including space
[:punct:] punctuation characters
- And here a some special char classes in perl:
perl POSIX equivalent Description
--------------------------------------------------------------------
\o [0-7] octal digit
\O [^0-7] non-octal digit
\w [[:alnum:]_] word character
\W [^[:alnum:]_] non-word character
\A [^[:alpha:]] non-alphabetic character
\L [^[:lower:]] non-lowercase character
\U [^[:upper:]] non-uppercase character
\S [^[:space:]] non-whitespace character
\D [^[:digit:]] non-digit
\X [^[:xdigit:]] non-hex digit
\P [^[:print:]] non-printable characters
\< [^[:alpha:]_] begin of word
\> [^[:alnum:]_] end of word
- note: posix char class must working in the square brackets. contrary,
perl's must stay outside of the brackets.
- And several alias has been created to help input some special char:
perl style POSIX style Description
-----------------------------------------------------------------------
\" [:dq:] double quotation
\' [:sq:] single quotation
\t [:tb:] table
\n [:nl:] new line (0x0A)
\r [:rt:] return (0x0D)
\b [:bs:] backspace
===============================================================================
TCL 8.2 Compatibal ARE expression:
- Use '***:' prefix with -r:, -ric:, -rnnl: or -rnnlic: to enable Advanced
Regular Expression mode. The ARE mode have more powerful expression then
POSIX BRE and ERE rule. And it has it's own char classes. More info at:
http://baiy.cn/utils/_regex_doc/index.htm
===============================================================================
RETURN CODE:
-1 - error occured when searching
0 - search successful
1 - search failed (pattern not found)
===============================================================================
SWITCH PREFIX and SUFFIX:
* All switchs (options) are case-insensitive (i.e: "-fic:" or "-FIC:")
* Switch Prefix can be either "-" or "/" (i.e: "/s" or "-s")
* Switch Suffix can be either ":" or "=" (i.e: "/f:", "/f=", "-f:" or "-f=")
===============================================================================
EXAMPLE:
f *.txt *.htm -f:something
f *.txt -l:15-20
f *.cpp *.hpp *.c *.h -fic:myfunc -o:"[F]:[l]:[o]nc"
f *.cpp *.h -r:"***:#define.*?MY_DEF"
type myfile.txt | f -f:BaiYang
expand -d *.cab | f -f:gdi32.dll
|