GLIMPSE(1)
β¨ GLIMPSE(1) β¨ β the manual page bestie π
okay so first of all, the manual name is glimpse and this is section 1 of the manual (General Commands Manual, if you're keeping score π
). buckle up, this one's a long one, but it's so worth it.
πΈ NAME πΈ
glimpse β search quickly through entire file systems. yes, entire. no cap. π¦
π OVERVIEW π
okay so. Glimpse β which stands for GLobal IMPlicit SEarch, iconic acronym behavior β is a very popular UNIX indexing and query system that lets you search through a large set of files very quickly. it's giving main character energy in the search-tool world, fr fr.
Glimpse supports most of agrep's options (agrep is our powerful version of grep, obsessed) including:
- approximate matching (like, finding misspelled words, which β relatable π)
- Boolean queries
- even some limited forms of regular expressions
you use it the same way as those other tools, except you don't have to specify file names. so if you're looking for a needle anywhere in your file system, all you have to do is say glimpse needle and every line containing needle will show up, preceded by the file name. that's it. that's the whole vibe. β¨
π‘ to use glimpse you first need to index your files withglimpseindex. for example,glimpseindex -o ~will index everything at or below your home directory. seeman glimpseindexfor more details. π
Glimpse is also available for web sites, as a set of tools called WebGlimpse. (the old glimpseHTTP is no longer supported and is not recommended, bestie β let it go π.) see http://webglimpse.net/ for more information.
Glimpse includes all of agrep, and can be used instead of agrep by giving a file name(s) at the end of the command. this causes glimpse to ignore the index and run agrep as usual. for example, glimpse -1 pattern file is the same as agrep -1 pattern file. Agrep is distributed as a self-contained package within glimpse, and can be used separately. we added a new option to agrep: -r searches recursively the directory and everything below it (see agrep options below); it is used only when glimpse reverts to agrep. π
Mail majordomo@webglimpse.net with SUBSCRIBE wgusers in the body to be added to the Webglimpse users mailing list. this is now the location where glimpse questions are also discussed. bugs can be reported at http://webglimpse.net/bugzilla/ β and an HTML version of these manual pages can be found at http://webglimpse.net/docs/glimpsehelp.html. also, see the glimpse home pages at http://webglimpse.net/glimpse π
π SYNOPSIS π
glimpse - [almost all letters] pattern
π INTRODUCTION π
we start with the simple ways to use glimpse and describe all the options in detail later on. once an index is built, using glimpseindex, searching for pattern is as easy as saying:
glimpse pattern
the output of glimpse is similar to that of agrep (or any other grep, honestly). the pattern can be any agrep legal pattern including a regular expression or a Boolean query β e.g., searching for Tucson AND Arizona is done by glimpse 'Tucson;Arizona'. cute, right? π
the speed of glimpse depends mainly on the number and sizes of the files that contain a match, and only to a second degree on the total size of all indexed files. if the pattern is reasonably uncommon, then all matches will be reported in a few seconds even if the indexed files total 500MB or more. some information on how glimpse works and a reference to a detailed article are given below. π₯
most of agrep's (and other grep's) options are supported, including approximate matching. for example:
glimpse -1 'Tuson;Arezona'
will output all lines containing both patterns allowing one spelling error in any of the patterns (either insertion, deletion, or substitution) β which in this case is definitely needed, no shade π
glimpse -w -i 'parent'
specifies case insensitive (-i) and match on complete words (-w). so 'Parent' and 'PARENT' will match, 'parent/child' will match, but 'parenthesis' or 'parents' will not match. (starting at version 3.0, glimpse can be much faster when these two options are specified, especially for very large indexes. you may want to set an alias especially for "glimpse -w -i" β do it, bestie, your future self will thank you π
)
the -F option provides a pattern that must match the file name. for example:
glimpse -F '\.c$' needle
will find the pattern needle in all files whose name ends with .c. (glimpse will first check its index to determine which files may contain the pattern, and then run agrep on the file names to further limit the search. iconic two-phase behavior β¨) the -F option should not be put at the end after the main pattern (e.g., "glimpse needle -F hay" is incorrect). π«
π A Detailed Description of All the Options of Glimpse π
-#β#is an integer between 1 and 8 specifying the maximum number of errors permitted in finding the approximate matches (the default is zero). generally, each insertion, deletion, or substitution counts as one error. it's possible to adjust the relative cost of insertions, deletions and substitutions (see-I-Dand-Soptions). since the index stores only lower case characters, errors of substituting upper case with lower case may be missed (see LIMITATIONS). allowing errors in the match requires more time and can slow down the match by a factor of 2-4. be very careful when specifying more than one error, as the number of matches tend to grow very quickly β it's giving exponential π³-aβ prints attribute names. this option applies only to Harvest SOIF structured data (used withglimpseindex -s). (seehttp://harvest.sourceforge.net/for more information about the Harvest project.) πΎ-Aβ used for glimpse internals. don't worry about it, it's not for us π«Ά-bβ prints the byte offset (from the beginning of the file) of the end of each match. the first character in a file has offset 0. π-Bβ Best match mode. β οΈ (Warning:-Bsometimes misses matches. it is safer to specify the number of errors explicitly.) when-Bis specified and no exact matches are found, glimpse will continue to search until the closest matches (i.e., the ones with minimum number of errors) are found, at which point the following message will be shown:
the best match contains x errors, there are y matches, output them? (y/n)
this message refers to the number of matches found in the index. there may be many more matches in the actual text (or there may be none if -F is used to filter files). when the -#, -c, or -l options are specified, the -B option is ignored. in general, -B may be slower than -#, but not by very much. since the index stores only lower case characters, errors of substituting upper case with lower case may be missed (see LIMITATIONS). π
-cβ Display only the count of matching records. only files with count > 0 are displayed. π’-Cβ tells glimpse to send its queries toglimpseserver. π‘-d 'delim'β Define delim to be the separator between two records. the default value is'$', namely a record is by default a line. delim can be a string of size at most 8 (with possible use of^and$), but not a regular expression. text between two delim's, before the first delim, and after the last delim is considered as one record. for example,-d '$$'defines paragraphs as records and-d '^From 'defines mail messages as records. glimpse matches each record separately. this option does not currently work with regular expressions. the-doption is especially useful for Boolean AND queries, because the patterns need not appear in the same line but in the same record. for example,glimpse -F mail -d '^From ' 'glimpse;arizona;announcement'will output all mail messages (in their entirety) that have the 3 patterns anywhere in the message (or the header), assuming that files with'mail'in their name contain mail messages. if you want the scope of the record to be the whole file, use the-Woption.
β οΈ Glimpse warning: Use this option with care. if the delimiter is set to match mail messages, for example, and glimpse finds the pattern in a regular file, it may not find the delimiter and will therefore output the whole file. (the -t option β see below β can be used to put the delim at the end of the record.) π
π₯ Performance Note: Agrep (and glimpse) resorts to more complex search when the -d option is used. the search is slower and unfortunately no more than 32 characters can be used in the pattern. brutal.
-Dkβ Set the cost of a deletion to k (k is a positive integer). this option does not currently work with regular expressions.-e patternβ Same as a simple pattern argument, but useful when the pattern begins with a'-'. π«Ά-Eβ prints the lines in the index (as they appear in the index) which match the pattern. used mostly for debugging and maintenance of the index. this is not an option that a user needs to know about. π-f file_nameβ this option has a different meaning for agrep than for glimpse: in glimpse, only the files whose names are listed in file_name are matched. (the file names have to appear as in.glimpse_filenames.) in agrep, the file_name contains the list of the patterns that are searched. (starting at version 3.6, this option for glimpse is much faster for large files.) β‘-F file_patternβ limits the search to those files whose name (including the whole path) matches file_pattern. this option can be used in a variety of applications to provide limited search even for one large index. if file_pattern matches a directory, then all files with this directory on their path will be considered. to limit the search to actual file names, use$at the end of the pattern. file_pattern can be a regular expression and even a Boolean pattern. this option is implemented by runningagrep file_patternon the list of file names obtained from the index. therefore, searching the index itself takes the same amount of time, but limiting the second phase of the search to only a few files can speed up the search significantly. for example:
glimpse -F 'src#\.c$' needle
will search for needle in all .c files with src somewhere along the path. the -F file_pattern must appear before the search pattern (e.g., glimpse needle -F '\.c$' will not work). it is possible to use some of agrep's options when matching file names. in this case all options as well as the file_pattern should be in quotes. (-B and -v do not work very well as part of a file_pattern.) for example:
glimpse -F '-1 \.html' pattern
will allow one spelling error when matching .html to the file names (so ".htm" and ".shtml" will match as well). π
glimpse -F '-v \.c$' counter
will search for 'counter' in all files except for .c files. π
-gβ prints the file number (its position in the.glimpse_filenamesfile) rather than its name. π’-Gβ outputs the whole entire files that contain a match π like, the full file, not just the matching lines. giving "here's the whole thing, you're welcome".-hβ do NOT display filenames π just the matches, no name-dropping.-Hdirectory_name β looks for the index and the other.glimpsefiles inside directory_name. default is your home directory π . this is soooo useful when you've got several different indexes for different archives (think: one for mail messages, one for source code, one for articles β you're a multi-archive girlie, periodt) π-iβ case-insensitive search β like,"A"and"a"are treated as equivalent, bestie, no cap. Glimpse's index stores all patterns in lower case (peep LIMITATIONS below π). Performance Note: when-iis used together with the-woption, the search may become much faster β‘ it is recommended to have-iand-was defaults, for example, through an alias. we use the following alias in our.cshrcfile:
alias glwi 'glimpse -w -i'
-Ikβ sets the cost of an insertion to k (k is a positive integer). β οΈ this option does not currently work with regular expressions. rip.-jβ if the index was constructed with the-toption, then-jwill output the files last modification dates in addition to everything else ποΈ no major performance penalties for this one, so it's basically free real estate.-Jhost_name β used in conjunction withglimpseserver(-C) to connect to one particular server π₯οΈβ¨-kβ no symbol in the pattern is treated as a meta character. for example,glimpse -k 'a(b|c)*d'will find the occurrences ofa(b|c)*dwhereasglimpse 'a(b|c)*d'will find substrings that match the regular expression'a(b|c)*d'. (the only exception is^at the beginning of the pattern and$at the end of the pattern, which are still interpreted in the usual way. use\^or\$if you need them verbatim π)-Kport_number β used in conjunction withglimpseserver(-C) to connect to one particular server at the specified TCP port number π-lβ output only the files names that contain a match π. this option differs from the-Noption in that the files themselves are searched, but the matching lines are not shown.-Lx | x:y | x:y:z β the limit queen π here's the tea:- if one number is given, it's a limit on the total number of matches. Glimpse outputs only the first x matches.
- if
-lis used (i.e., only file names are sought), then the limit is on the number of files; otherwise, the limit is on the number of records. - if two numbers are given (x:y), then y is an added limit on the total number of files.
- if three numbers are given (x:y:z), then z is an added limit on the number of matches per file.
- if any of the x, y, or z is set to
0, it means to ignore it (in other words0= infinity in this case π); for example,-L 0:10will output all matches to the first 10 files that contain a match. - this option is particularly useful for servers that needs to limit the amount of output provided to clients.
-mβ used for glimpse internals π€« don't worry about it.-Mβ used for glimpse internals π€« same vibe, also internal.-nβ each matching record (line) is prefixed by its record (line) number in the file π’. Performance Note: to compute the record/line number,agrepneeds to search for all record delimiters (or line breaks), which can slow down the search. so, a lil cost, but you get numbers.-Nβ searches only the index (so the search is faster πββοΈπ¨). okay this one has LAYERS:- if
-oor-bare used then the result is the number of files that have a potential match plus a prompt to ask if you want to see the file names. (if-yis used, then there is no prompt and the names of the files will be shown.) - this could be a way to get the matching file names without even having access to the files themselves π€―
- however, because only the index is searched, some potential matches may not be real matches. in other words, with
-Nyou will not miss any file but you may get extra files. for example, since the index stores everything in lower case, a case-sensitive query may match a file that has only a case-insensitive match. Boolean queries may match a file that has all the keywords but not in the same line (indexing with-ballows glimpse to figure out whether the keywords are close, but it cannot figure out from the index whether they are exactly on the same line or in the same record without looking at the file). - if the index was not build with
-oor-b, then this option outputs the number of blocks matching the pattern. this is useful as an indication of how long the search will take. all files are partitioned into usually 200-250 blocks. the file.glimpse_statisticscontains the total number of blocks (orglimpse -N awill give a pretty good estimate; only blocks with no occurrences of'a'will be missed).
- if
-oβ the opposite of-t: the delimiter is not output at the tail, but at the beginning of the matched record π-Oβ the file names are not printed before every matched record; instead, each filename is printed just once, and all the matched records within it are printed after it. tidy β¨-pβ (from version 4.0B1 only) supports reading compressed set of filenames π¦. the-poption allows you to utilize compressedneighborhoods(sets of filenames) to limit your search, without uncompressing them. added mostly for WebGlimpse. the usage is:"-p filename:X:Y:Z"where:"filename"is the file with compressed neighborhoods,Xis an offset into that file (usually0, must be a multiple ofsizeof(int)),Yis the length glimpse must access from that file (if0, then whole file; must be a multiple ofsizeof(int)),- and
Zmust be2(it indicates that"filename"has the sparse-set representation of compressed neighborhoods: the other values are for internal use only).
note that any colon ":" in filename must be escaped using a backslash \ β οΈ
-Pβ used for glimpse internals π€« you guessed it.-qβ prints the offsets of the beginning and end of each matched record π. the difference between-qand-bis that-bprints the offsets of the actual matched string, while-qprints the offsets of the whole record where the match occurred. the output format is@x{y}, where x is the beginning offset and y is the end offset.-Qβ when used together with-N, glimpse not only displays the filename where the match occurs, but the exact occurrences (offsets) as seen in the index π. this option is relevant only if the index was built with-b; otherwise, the offsets are not available in the index. this option is ignored when used not with-N.-rβ this option is anagrepoption and it will be ignored in glimpse, unless glimpse is used with a file name at the end which makes it run asagrep. if the file name is a directory name, the-roption will search (recursively) the whole directory and everything below it π³. (the glimpse index will not be used.)-Rk β defines the maximum size (in bytes) of a record π. the maximum value (which is the default) is 48K. defining the maximum to be lower than the default may speed up some searches β‘-sβ work silently, that is, display nothing except error messages π€. this is useful for checking the error status.-Skβ set the cost of a substitution to k (k is a positive integer). β οΈ this option does not currently work with regular expressions.-tβ similar to the-doption, except that the delimiter is assumed to appear at the end of the record. glimpse will output the record starting from the end of delim to (and including) the next delim. (see warning for the-doption. β οΈ)-Tdirectory β use directory as a place where temporary files are built ποΈ. (glimpse produces some small temporary files usually in/tmp.) this option is useful mainly in the context of structured queries for the Harvest project, where the temporary files may be non-trivial, and the/tmpdirectory may not have enough space for them.-Uβ (starting at version 4.0B1) interprets an index created with the-Xor the-Uoption inglimpseindex. useful mostly for WebGlimpse or similar web applications π. when glimpse outputs matches, it will display the filename, the URL, and the title automatically.-vβ (this option is anagrepoption and it will be ignored in glimpse, unless glimpse is used with a file name at the end which makes it run asagrep.) output all records/lines that do not contain a match. (glimpse does not support the NOT operator yet. π)-Vβ prints the current version of glimpse π·οΈ-wβ search for the pattern as a word β i.e., surrounded by non-alphanumeric characters π€. for example,glimpse -w carwill matchcar, but notcharactersand notcar10. the non-alphanumeric must surround the match; they cannot be counted as errors. β οΈ this option does not work with regular expressions. Performance Note: when-wis used together with the-ioption, the search may become much faster β‘ the-wwill not work with$,^, and_(see BUGS below π). it is recommended to have-iand-was defaults, for example, through an alias. we use the following alias in our.cshrcfile:
alias glwi 'glimpse -w -i'
-Wβ the default for Boolean AND queries is that they cover one record (the default for a record is one line) at a time. for example,glimpse 'good;bad'will output all lines containing both'good'and'bad'. the-Woption changes the scope of Booleans to be the whole file π. within a file glimpse will output all matches to any of the patterns. so,glimpse -W 'good;bad'will output all lines containing'good'or'bad', but only in files that contain both patterns. the NOT operator'~'can be used only with-W. it is described later on. the OR operator is essentially unaffected (unless it is in combination with the other Boolean operations). for structured queries, the scope is always the whole attribute or file.-xβ the pattern must match the whole line π. (this option is translated to-wwhen the index is searched and it is used only when the actual text is searched. it is of limited use in glimpse.)-Xβ (from version 4.0B1 only, bestie, so if you're on something older this one just isn't there) it outputs the names of files that contain a match even if those files got deleted after the index was built. Without this option? glimpse just pretends they never existed and ignores them entirely. π-yβ no prompting, no asking, no waiting. It just proceeds with the match as if the answer to literally any prompt isy. Servers (or honestly any other scripts) using glimpse will probably want this one. Automate it, queen. π€-Yk β okay so if the index was built with the-toption, then-Y xwill output only matches to files that were created or modified within the last x days. There are no major performance penalties for this option, so you can be nosy about recent files for free. β¨-zβ allow customizable filtering, using the file.glimpse_filtersto run the programs listed in there for each match. The best example is compress/decompress. So if.glimpse_filtersincludes the line
*.Z uncompress <
(separated by tabs, not vibes) then before indexing any file that matches the pattern "*.Z" (same syntax as the one for .glimpse_exclude) the command listed gets executed first β assuming input is from stdin, which is why uncompress needs that < β and its output (assuming it goes to stdout) is what gets indexed. The file itself is not changed (i.e., it stays compressed). Then if glimpse -z is used, the same program is used on these files on the fly. Any program can be used (we run 'exec'). For example, one can filter out parts of files that should not be indexed. Glimpseindex tries to apply all filters in .glimpse_filters in the order they are given. For example, if you want to uncompress a file and then extract some part of it, put the compression command (the example above) first and then another line that specifies the extraction. Note that this can slow down the search because the filters need to be run before files are searched. (See also glimpseindex.)
-Zβ no op. (It's useful for glimpse's internals. Trust us.) π«Ά
The characters $, ^, β, [, ], ^, |, (, ), !, and \ can cause unexpected results when included in the pattern, because these characters are also meaningful to the shell. To dodge all that mess, enclose the entire pattern in single quotes, i.e., 'pattern'. Do not use double quotes ("). Like, do not. π
β¨ PATTERNS β¨
glimpse supports a large variety of patterns, including simple strings, strings with classes of characters, sets of strings, wild cards, and regular expressions (see LIMITATIONS). It's giving range. π
Strings πΈ
Strings are any sequence of characters, including the special symbols ^ for beginning of line and $ for end of line. The following special characters ($, ^, β, [, ^, |, (, ), !, and \) as well as the following meta characters special to glimpse (and agrep): ;, ,, #, <, >, -, and ., should be preceded by \ if they are to be matched as regular characters.
For example, \^abc\\ corresponds to the string ^abc\, whereas ^abc corresponds to the string abc at the beginning of a line. See the difference? Iconic.
Classes of characters π
A list of characters inside [] (in order) corresponds to any character from the list. For example, [a-ho-z] is any character between a and h or between o and z.
The symbol ^ inside [] complements the list. For example, [^i-n] denotes any character in the character set except character 'i' to 'n'. The symbol ^ thus has two meanings, but this is consistent with egrep, so it's fine, it's canon.
The symbol . (don't care) stands for any symbol (except for the newline symbol). π¦
Boolean operations π₯
glimpse supports:
- an
ANDoperation denoted by the symbol; - an
ORoperation denoted by the symbol, - a limited version of a
NOToperation (starting at version 4.0B1) denoted by the symbol~ - or any combination of the above
For example, glimpse 'pizza;cheeseburger' will output all lines containing both patterns.
glimpse -F 'gnu;\.c$' 'define;DEFAULT' will output all lines containing both 'define' and 'DEFAULT' (anywhere in the line, not necessarily in order) in files whose name contains 'gnu' and ends with .c.
glimpse '{political,computer};science' will match 'political science' or 'science of computers'.
The NOT operation works only together with the -W option and it generally applies only to the whole file rather than to individual records. Its output may sometimes seem counterintuitive. Use with care. π
glimpse -W 'fame;~glory' will output all lines containing 'fame' in all files that contain 'fame' but do not contain 'glory' β this is the most common use of NOT, and in this case it works as expected.
glimpse -W '~{fame;glory}' will be limited to files that do not contain both words, and will output all lines containing one of them.
Wild cards π¦
The symbol # is used to denote a sequence of any number (including 0) of arbitrary characters (see LIMITATIONS). The symbol # is equivalent to .* in egrep.
In fact, .* will work too, because it is a valid regular expression (see below), but unless this is part of an actual regular expression, # will work faster.
(Currently glimpse is experiencing some problems with #.) π
Combination of exact and approximate matching π
Any pattern inside angle brackets <> must match the text exactly, even if the match is with errors.
For example, <mathemat>ics matches mathematical with one error (replacing the last s with an a), but mathe<matics> does not match mathematical no matter how many errors are allowed.
(This option is buggy at the moment.) π
Regular expressions π
Since the index is word based, a regular expression must match words that appear in the index for glimpse to find it.
glimpse first strips the regular expression from all non-alphabetic characters, and searches the index for all remaining words. It then applies the regular expression matching algorithm to the files found in the index.
For example, glimpse 'abc.*xyz' will search the index for all files that contain both 'abc' and 'xyz', and then search directly for 'abc.*xyz' in those files.
(If you use glimpse -w 'abc.*xyz', then 'abcxyz' will not be found, because glimpse will think that abc and xyz need to be matches to whole words.)
The syntax of regular expressions in glimpse is in general the same as that for agrep. The union operation |, Kleene closure *, and parentheses () are all supported. Currently + is not supported.
Regular expressions are currently limited to approximately 30 characters (generally excluding meta characters).
Some options (-d,-w,-t,-x,-D,-I,-S) do not currently work with regular expressions.
The maximal number of errors for regular expressions that use*or|is 4. (See LIMITATIONS.)
structured queries π§
glimpse supports some form of structured queries using Harvest's SOIF format. See STRUCTURED QUERIES below for details. iykyk. β¨
π EXAMPLES π
(Run "glimpse '^glimpse' this-file" to get a list of all examples, some of which were given earlier.) Bestie, the manpage has a manpage. π
glimpse -F 'haystack.h$' needle
finds all needles in all haystack.h's files. πͺ‘
glimpse -2 -F html Anestesiology
outputs all occurrences of Anestesiology with two errors in files with html somewhere in their full name.
glimpse -l -F '\.c$' variablename
lists the names of all .c files that contain variablename (the -l option lists file names rather than output the matched lines).
glimpse -F 'mail;1993' 'windsurfing;Arizona'
finds all lines containing windsurfing and Arizona in all files having mail and '1993' somewhere in their full name. π
glimpse -F mail 't.j@#uk'
finds all mail addresses (search only files with mail somewhere in their name) from the uk, where the login name ends with t.j, where the . stands for any one character. (This is very useful to find a login name of someone whose middle name you don't know.) π΅οΈ
glimpse -F mbox -h -G . > MBOX
concatenates all files whose name matches mbox into one big one.
πΎ SEARCHING IN COMPRESSED FILES πΎ
glimpse includes an optional new compression program, called cast, which allows glimpse (and agrep) to search the compressed files without having to decompress them. And honestly? The search is actually significantly faster when the files are compressed. β‘
However, we have not tested cast as thoroughly as we would have liked, and a mishap in a compression algorithm can cause loss of data, so we recommend at this point to use cast very carefully.
We do not support or maintain cast.
(Unless you specifically use cast, the default is to ignore it.) πΈ
β¨ GLIMPSEINDEX FILES β¨
okay bestie, real talk: every file glimpse uses lives in the directory(ies) where the index(es) is (are) stored, and they all have .glimpse_ as a prefix. The first two files (.glimpse_exclude and .glimpse_include) are optionally supplied by you, the user. The other files are built and read by glimpse. no cap. π
.glimpse_exclude
This one contains a list of files that glimpseindex is explicitly told to ignore. In general, the syntax of .glimpse_exclude/include is the same as that of agrep (or any other grep). The lines in the .glimpse_exclude file are matched to the file names, and if they match, the files are excluded. Notice that agrep matches to parts of the string! e.g., agrep /ftp/pub will match /home/ftp/pub and /ftp/pub/whatever. So, if you want to exclude /ftp/pub/core, you just list it, as is, in the .glimpse_exclude file. If you put "/home/ftp/pub/cdrom" in .glimpse_exclude, every file name that matches that string will be excluded, meaning all files below it. You can use ^ to indicate the beginning of a file name, and $ to indicate the end of one, and you can use * and ? in the usual way. For example /ftp/*html will exclude /ftp/pub/foo.html, but will also exclude /home/ftp/pub/html/whatever; if you want to exclude files that start with /ftp and end with html use ^/ftp*html$. Notice that putting a * at the beginning or at the end is redundant (in fact, in this case glimpseindex will remove the * when it does the indexing). No other meta characters are allowed in .glimpse_exclude (e.g., don't use .* or # or |). Lines with * or ? must have no more than 30 characters. Notice that, although the index itself will not be indexed, the list of file names (.glimpse_filenames) will be indexed unless it is explicitly listed in .glimpse_exclude. iykyk π
.glimpse_filters
See the description above for the -z option. that's it bestie β¨
.glimpse_include
contains a list of files that glimpseindex is explicitly told to include in the index even though they may look like non-text files. Symbolic links are followed by glimpseindex only if they are specifically included here. If a file is in both .glimpse_exclude and .glimpse_include it will be excluded.
.glimpse_filenames
contains the list of all indexed file names, one per line. This is an ASCII file that can also be used with agrep to search for a file name leading to a fast find command. For example,
glimpse 'count#\.c$' ~/.glimpse_filenames
will output the names of all (indexed) .c files that have 'count' in their name (including anywhere on the path from the index). Setting the following alias in the .login file may be useful:
alias findfile 'glimpse -h :1 ~/.glimpse_filenames'
obsessed with this trick π
.glimpse_index
contains the index. The index consists of lines, each starting with a word followed by a list of block numbers (unless the -o or -b options are used, in which case each word is followed by an offset into the file .glimpse_partitions where all pointers are kept). The block/file numbers are stored in binary form, so this is not an ASCII file. π
.glimpse_messages
contains the output of the -w option (see above).
.glimpse_partitions
contains the partition of the indexed space into blocks and, when the index is built with the -o or -b options, some part of the index. This file is used internally by glimpse and it is a non-ASCII file.
.glimpse_statistics
contains some statistics about the makeup of the index. Useful for some advanced applications and customization of glimpse. main character energy for advanced users β¨
.glimpse_turbo
An added data structure (used under glimpseindex -o or -b only) that helps to speed up queries significantly for large indexes. Its size is 0.25MB. Glimpse will work without it if needed. lowkey optional but highkey helpful π
𧬠STRUCTURED QUERIES π§¬
Glimpse can search for Boolean combinations of "attribute=value" terms by using the Harvest SOIF parser library (in glimpse/libtemplate). To search this way, the index must be made by using the -s option of glimpseindex (this can be used in conjunction with other glimpseindex options). For glimpse and glimpseindex to recognize "structured" files, they must be in SOIF format. In this format, each value is prefixed by an attribute-name with the size of the value (in bytes) present in "{}" after the name of the attribute. For example, The following lines are part of an SOIF file:
type{17}: Directory-Listing
md5{32}: 3858c73d68616df0ed58a44d306b12ba
Any string can serve as an attribute name. Glimpse "pattern;type=Directory-Listing" will search for "pattern" only in files whose type is "Directory-Listing". The file itself is considered to be one "object" and its name/url appears as the first attribute with an "@" prefix; e.g., @FILE { http://xxx... } The scope of Boolean operations changes from records (lines) to whole files when structured queries are used in glimpse (since individual query terms can look at different attributes and they may not be "covered" by the record/line). Note that glimpse can only search for patterns in the value parts of the SOIF file: there are some attributes (like the TTL, MD5, etc.) that are interpreted by Harvest's internal routines. See RFC 2655 for more detailed information of the SOIF format. structured slay π
π REFERENCES π
- U. Manber and S. Wu,
"GLIMPSE: A Tool to Search Through Entire File Systems,"Usenix Winter 1994 Technical Conference (best paper award), San Francisco (January 1994), pp. 23-32. Also, Technical Report#TR 93-34, Dept. of Computer Science, University of Arizona, October 1993 (a postscript file is available by anonymous ftp atftp://webglimpse.net/pub/glimpse/TR93-34.ps). - S. Wu and U. Manber,
"Fast Text Searching Allowing Errors,"Communications of the ACM 35 (October 1992), pp. 83-91.
the receipts, bestie π
π SEE ALSO π
agrep(1), ed(1), ex(1), glimpseindex(1), glimpseserver(1), grep(1), sh(1), csh(1). go read these too π
π§ LIMITATIONS π§
The index of glimpse is word based. A pattern that contains more than one word cannot be found in the index. The way glimpse overcomes this weakness is by splitting any multi-word pattern into its set of words and looking for all of them in the index. For example, glimpse 'linear programming' will first consult the index to find all files containing both linear and programming, and then apply agrep to find the combined pattern. This is usually an effective solution, but it can be slow for cases where both words are very common, but their combination is not. π
As was mentioned in the section on PATTERNS above, some characters serve as meta characters for glimpse and need to be preceded by '\' to search for them. The most common examples are the characters '.' (which stands for a wild card), and '*' (the Kleene closure). So, glimpse ab.de will match abcde, but glimpse ab\.de will not, and glimpse ab*de will not match ab*de, but glimpse ab\*de will. The meta character - is translated automatically to a hyphen unless it appears between [] (in which case it denotes a range of characters). the way that backslash changes everything π
The index of glimpse stores all patterns in lower case. When glimpse searches the index it first converts all patterns to lower case, finds the appropriate files, and then searches the actual files using the original patterns. So, for example, glimpse ABCXYZ will first find all files containing abcxyz in any combination of lower and upper cases, and then searches these files directly, so only the right cases will be found. One problem with this approach is discovering misspellings that are caused by wrong cases. For example, glimpse -B abcXYZ will first search the index for the best match to abcxyz (because the pattern is converted to lower case); it will find that there are matches with no errors, and will go to those files to search them directly, this time with the original upper cases. If the closest match is, say, AbcXYZ, glimpse may miss it, because it doesn't expect an error. Another problem is speed. If you search for "ATT", it will look at the index for "att". Unless you use -w to match the whole word, glimpse may have to search all files containing, for example, "Seattle" which has "att" in it. the case-sensitivity plot twist π
There is no size limit for simple patterns and simple patterns within Boolean expressions. More complicated patterns, such as regular expressions, are currently limited to approximately 30 characters. Lines are limited to 1024 characters. Records are limited to 48K, and may be truncated if they are larger than that. The limit of record length can be changed by modifying the parameter Max_record in agrep.h.
Glimpseindex does not index words of size > 64. 64 is the limit, periodt
π BUGS π
- In some rare cases, regular expressions using
*or#may not match correctly. - A query that contains no alphanumeric characters is not recommended (unless glimpse is used as
agrepand the file names are provided). This is an understatement. - The notion of
"match to the whole word"(the-woption) can be tricky sometimes. For example,glimpse -w 'word$'will not match'word'appearing at the end of a line, because the extra'$'makes the pattern more than just one simple word. The same thing can happen with^and with_. To be on the safe side, use the-woption only when the patterns are actual words. - Please send bug reports or comments to
gvelez@webglimpse.net. they wanna hear from you π
π©Ί DIAGNOSTICS π©Ί
Exit status is 0 if any matches are found, 1 if none, 2 for syntax errors or inaccessible files. simple as that β¨
π AUTHORS π
Udi Manber and Burra Gopal, Department of Computer Science, University of Arizona, and Sun Wu, the National Chung-Cheng University, Taiwan. Now maintained by Golda Velez at Internet WorkShop (Email: gvelez@webglimpse.net) icons only π
okay that's a wrap, bestie π this was GLIMPSE(1), dated November 10, 1997 β mwah πβ¨
π¦ where this page comes from
- debian bookworm: glimpse 4.18.7-6
- debian trixie: glimpse 4.18.7-10
- ubuntu jammy: glimpse 4.18.7-6
- ubuntu noble: glimpse 4.18.7-8build1
- ubuntu questing: glimpse 4.18.7-11
- ubuntu resolute: glimpse 4.18.7-12
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms