How to do things
AI Noob vs. Pro
List biggest files
List newest files
Show subdir sizes
Search in files
Replace word in files
List dir differences
Send files in LAN
Free Open Source:
Swiss File Knife
a command line multi function tool.
Depeche View
Source Research
First Steps
windows GUI automation
command line
file encryption
free external tools,
zero install effort,
usb stick compliant:
cpp sources
articles
 |
How to find lines in text files by typing simple English commands How to search many text files for lines having a word1, OR
another word2, but NOT containing another word3,
using plain English operators, with a Freeware tool for Windows and Linux/Mac.
|
After download, run the tool by double click, then click on Open
and select a directory from which you want to load all text files.
All ASCII text files from that folder will be loaded, like all
.txt, .ini, .html, readme or source code files.
combined search expressions
Imagine you want to find all text lines containing the words
"foo" OR "bar"
then simply type
foo OR bar
into the FIND mask:
Note that you must type exactly " OR ", that is BLANK, BIG O,
BIG R, BLANK. A lowercase " or " will be treated as normal text.
The result lines, across all text files, are shown immediately:
Just click into any result line to jump to that text location.
logical operators for the search text
And where is OR, there is AND, and ... one example:
If you type
candy AND bar*banana NOT foobar
you are searching lines
- containing "candy"
- and having "bar" and "banana" in their text
- but excluding lines containing "foobar"
NOTE that the wildcard "*" is basically the same as AND.
The full list of supported operators:
AND find lines with both words
* same as AND, only shorter
OR find lines having one word or the other
NOT exclude lines having the word
TAB find TAB characters within text
LSTART or LS Pro: find only lines starting with that word
LEND Pro: find only lines ending with that word
WORD Pro: find a word made from a-z, 0-9 and _
COLx[START/END/FULL] Pro: search columns of TAB separated data.
for more on that see below.
When using a mix of AND, OR and NOT, always place NOT phrases last.
For example, when typing
foo NOT foobar AND footer
the intention is not clear: should foobar and footer be excluded,
or do you want to find lines with foo AND footer, excluding foobar?
Actually, dview will show an error and ignore "AND footer".
To make it work, rewrite the query like:
foo NOT foobar NOT footer
More examples:
"class *bar* obj OR warn NOT goo"
finds lines containing "class FooBar: public Obj" or "warning"
but not "CGooBar".
"LS class OR LEND ;"
finds lines beginning with class or ending with ;
"WORD i"
finds places where "i" is used as an isolated word, like in
for (int i=0; i<10; i++)
| | | |
no hit hit hit hit
"foo TAB bar"
finds "foo bar" with a single TAB character inbetween.
Type just "TAB" to find the word "TAB", but type "TAB " (with a blank)
to find all TAB characters. And to highlight the actual TAB characters
within the search results, press CTRL+T.
escaping search operators
To find the * character itself, type **,
for example "/** foo" actually finds "/* foo".
Alternatively, you may switch off wildcard detection via
the Mode button, then AND OR NOT ... or by pressing CTRL+F4.
If you need to find "foo *bar" with any chars allowed inbetween,
use "foo AND **bar".
If you really need to search the literal string "foo AND bar" in
case sensitive mode, type "foo \AND bar" instead. If you need to
search "foo \AND bar", press CTRL+F4 to switch operators off.
disabling the search word sequence checking
If you search "foo*bar*banana", you will only find lines where
- "bar" appears AFTER "foo"
- "banana" appears AFTER "bar"
Now, if you want to find lines having any combination of those words,
no matter in what sequence, click on the "noseq" button at the right
bottom or press SHIFT+F4. (The button appears as soon as there is
a search phrase containing * or AND).
logical operators for the path
Just as in the FIND mask, you can write the PATH mask like:
foosys OR candy OR .cpp NOT .bak
which selects all files
- having foosys in their name
- OR having candy in their name
- OR having .cpp in their name
- however EXCLUDING all files having .bak in their name
NOTE: in the PATH mask, "AND" is the same as "OR".
|