GLIMPSEINDEX(1)
β¨ GLIMPSEINDEX β¨
the GLIMPSEINDEX(1) page, bestie β General Commands Manual, and yes we are reading the whole thing π«Ά
πΈ NAME πΈ
glimpseindex β index whole file systems to be searched by glimpse
π OVERVIEW π
okay so. Glimpse (which stands for GLobal IMPlicit SEarch) is a popular UNIX indexing and query system that lets you search through a large set of files very quickly. Glimpseindex is the indexing program for glimpse. π
Glimpse supports most of agrep's options (agrep is our powerful version of grep) including approximate matching (like, finding misspelled words β¨), Boolean queries, and even some limited forms of regular expressions. You use it the same way, 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 all lines containing needle will appear preceded by the file name. πͺ‘ See man glimpse for the deets on how to use glimpse.
Glimpseindex provides three indexing options: a tiny index (2-3% of the total size of all files), a small index (7-8%) and a medium-size index (20-30%). Search times are normally better with larger indexes (although unless files are quite large, the small index is just about as good as the medium one). To index all your files, you say:
glimpseindex ~for tiny index (where~stands for the home directory)glimpseindex -o ~for small indexglimpseindex -b ~for medium
π Please submit bug reports or comments athttp://webglimpse.net/bugzilla/. Mailmajordomo@webglimpse.netwithSUBSCRIBE WGUSERSin the message body to be added to the webglimpse mailing list, where glimpse discussion is also directed. HTML version of these manual pages can be found inhttp://webglimpse.net/docs/glimpseindexhelp.html. Also, see the glimpse home pages inhttp://webglimpse.net/glimpse/
π SYNOPSIS π
glimpseindex [ -abEfFiInostT -w number -dD filename(s) -H directory -M
number -S number ] directory_name[s]
π¦ INTRODUCTION π¦
Glimpseindex builds an index of all text files in all the directories specified and all their subdirectories (recursively). It's also possible to build several separate indexes (possibly even overlapping, bestie, we love a flexible queen π). The simplest way to index your files is to say
glimpseindex -o ~
The index consists of several files (described in detail below), all with the prefix .glimpse_ stored in the user's home directory (unless otherwise specified with the -H option). Files with one of the following suffixes are not indexed: ".o", ".gz", ".Z", ".z", ".hqx", ".zip", ".tar". (Unless the -z option is used, see below.) In addition, glimpseindex attempts to determine whether a file is a text file and does not index files that it thinks are not text files. Numbers are not indexed unless the -n option is used. It is possible to prevent specified files from being indexed by adding their names to the .glimpse_exclude file (described below). β¨
The -o option builds a larger index than without it (typically about 7-8% vs. 2-3% without -o) allowing for a faster search (1-5 times faster). The -b builds an even larger index and allows an even faster search some of the time (-b is helpful mostly when large files are present). There is an incremental indexing option -f, which updates an existing index by determining which files have been created or modified since the index was built and adding them to the index (see -f). Glimpseindex is reasonably fast, taking about 20 minutes to index 15,000 files of about 200MB (on an Dec Alpha 233) and 2-4 minutes to update an existing index. (Your mileage may vary.) It is also possible to increment the index by adding a specific file (the -a option).
Once an index is built, searching for pattern is as easy as saying
glimpse pattern
(See man glimpse for all glimpse's options and features.)
π A DETAILED DESCRIPTION OF GLIMPSEINDEX π
Glimpse does not automatically index files. You have to tell it to do it. You can do it manually, but a better way is to set it to run every night. π It's probably a good idea to run glimpseindex manually for the first time to be sure it works properly. The following is a simple script to run glimpseindex every night. We assume that this script is stored in a file called glimpse.script:
glimpseindex -o -t -w 5000 ~ >& .glimpse_out
at -m 0300 glimpse.script
(It might be interesting to collect all the outputs of glimpse by changing >& to >>& so that the file .glimpse_out maintains a history. In this case the file must be created before the first time >>& is used. If you use ksh, replace '>&' with '2>&1'.)
Glimpseindex stores the names of all the files that it indexed in the file .glimpse_filenames. Each file is listed by its full path name as obtained at the time the files were indexed. For example, /usr1/udi/file1. Glimpse uses this full name when it performs the search, so the name must match the current name. This may become a problem when the indexing and the search are done from different machines (e.g., through NFS), which may cause the path names to be different. For example, /tmp_mnt/R/xxx/xxx/usr1/udi/file1. (The same is true for several other .glimpse files. See below.) π
Glimpseindex does not follow symbolic links unless they are explicitly included in the .glimpse_include file (described below).
Glimpseindex makes an effort to identify non-text files such as binary files, compressed files, uuencoded files, postscript files, binhex files, etc. These files are automatically not indexed. In addition, all files whose names end with .o, .gz, .Z, .z, .hqx, .zip, or .tar will not be indexed (unless they are specifically included in .glimpse_include β see below).
The options for glimpseindex are as follows:
-aβ adds the given file[s] and/or directories to an existing index. Any given directory will be traversed recursively and all files will be indexed (unless they appear in.glimpse_exclude; see below). Using this option is generally much faster than indexing everything from scratch, although in rare cases the index may not be as good. If for some reason the index is full (which can happen unless-oor-bare used)glimpseindex -awill produce an error message and will exit without changing the original index. β οΈ-bβ builds a medium-size index (20-30% of the size of all files), allowing faster search. This option forcesglimpseindexto store an exact (byte level) pointer to each occurrence of each word (except for some very common words belonging to the stop list).-Bβ uses a hash table that is 4 times bigger (256kentries instead of64K) to speed up indexing. The memory usage will increase typically by about 2 MB. This option is only for indexing speed; it does not affect the final index. π₯-d filename(s)β deletes the given file(s) from the index.-D filename(s)β deletes the given file(s) from the list of file names, but not from the index. This is much faster than-d, and the file(s) will not be found byglimpse. However, the index itself will not become smaller. (so like, sneaky delete, the data's still living there rent free π)-Eβ does not run a check on file types. Glimpse normally attempts to exclude non-text files, but this attempt is not always perfect. With-E,glimpseindexindexes all files, except those that are specifically excluded in.glimpse_excludeand those whose file names end with one of the excluded suffixes.-fβ incremental indexing.glimpseindexscans all files and adds to the index only those files that were created or modified after the current index was built. If there is no current index or if this procedure fails,glimpseindexautomatically reverts to the default mode (which is to index everything from scratch). This option may create an inefficient index for several reasons, one of which is that deleted files are not really deleted from the index. Unless changes are small, mostly additions, and-ois used, we suggest to use the default mode as much as possible. π-Fβ Glimpseindex receives the list of files to index from standard input.-H directoryβ Put or update the index and all other.glimpsefiles (listed below) in "directory". The default is the home directory. Whenglimpseis run, the-Hoption must be used to directglimpseto this directory, becauseglimpseassumes that the index is in the home directory (see also the-Hoption inglimpse). π-iβ Make.glimpse_include(SEE GLIMPSEINDEX FILES) take precedence over.glimpse_exclude, so that, for example, one can exclude everything (by putting*) and then explicitly include files.-Iβ Instead of indexing, only show (print to standard out) the list of files that would be indexed. It is useful for filtering purposes. ("glimpseindex -I dir | glimpseindex -F"is the same as"glimpseindex dir".) π-M xβ Tellsglimpseindexto use x MB of memory for temporary tables. The more memory you allow the fasterglimpseindexwill run. The default isx=2. The value of x must be a positive integer. Glimpseindex will need more memory than x for other things, andglimpseindexmay perform some 'forks', so you'll have to experiment if you want to use this option. WARNING: If x is too large you may run out of swap space. π¨-nβ Index numbers as well as text. The default is not to index numbers. This is useful when searching for dates or other identifying numbers, but it may make the index very large if there are lots of numbers. In general,glimpseindexstrips away any non-alphabetic character. For example, the stringabc123will be indexed asabcif the-noption is not used and asabc123if it is used. Glimpse provides warnings (in.glimpse_messages) for all files in which more than half the words that were added to the index from that file had digits in them (this is an attempt to identify data files that should probably not be indexed). One can use the.glimpse_excludefile to exclude data files or any other files. (See GLIMPSEINDEX FILES.) π’-oβ Build a small index rather than tiny (meaning 7-9% of the sizes of all files β your mileage may vary) allowing faster search. This option forcesglimpseindexto allocate one block per file (a block usually contains many files). A detailed explanation of how blocks affect glimpse can be found in the glimpse article. (See also LIMITATIONS.)-Rβ recomputes.glimpse_filenames_indexfrom.glimpse_filenames. π« That.glimpse_filenames_indexfile is literally just a speed booster βglimpseindexusually builds it for you automatically, no thoughts required. BUT if you ever wanna switch up the path names of the files listed in.glimpse_filenames, thenglimpseindex -Ris the move: it rebuilds.glimpse_filenames_indexfor you. Super handy when the index got computed on one machine but you're using it on another (with the same hierarchy, bestie, same hierarchy). The names of the files in.glimpse_filenamesare what gets used at runtime, so you can change them whenever and however you want β as long as you're only touching the names, not the content. Heads up tho: this isn't really an option in the normal sense, it's more like a whole program by itself, meant as a post-processing step. (Available only from version 3.6.) β¨-sβ supports structured queries. This one got added to support the Harvest project, so it's applicable mostly in that context. Peep STRUCTURED QUERIES below for more info, and alsohttp://harvest.sourceforge.net/for the whole Harvest project tea. π«Ά-S kβ the number k sets the size of the stop-list. So what even is a stop-list? It's the words that are too common and therefore don't get indexed (think'the'or'and'β nobody's searching those, be serious). Instead of a fixed stop-list,glimpseindexfigures out which words are too common for every index separately. The rules hit different for the different indexing options:- The tiny index contains all words (the savings from a stop-list are too small to bother, not worth the drama).
- For the small index (
-o), k is a percentage threshold: a word lands in the stop list if it shows up in at least k% of all files. Default is80%. (If there are less than 256 files, then the stop-list is not maintained.) - For the medium index (
-b), it counts all occurrences of all words, and a word gets added to the stop-list if it appears at least k times per MByte. Default is500.
A query that includes a stop list word is, of course, less efficient π. (See also LIMITATIONS below.)
-tβ (a new option in version 3.5, glow up era). Normally the order files get indexed in is determined by scanning the directories, which is mostly arbitrary β kinda random tbh. With-t, combined with either-oand-b, the indexed files get stored in reversed order of modification age (younger files first πΆ). Results of queries then automatically come back in this order. ANDglimpsecan filter results by age β like asking to only look at files that are at most 5 days old. obsessed. β-Tβ builds the turbo file. Starting at version 3.0 this is the default, so using this option has no effect. It's giving legacy. π-w kβ soglimpseindexdoes a reasonable but not perfect job of figuring out which files should not be indexed. Sometimes a big text file really shouldn't be indexed β like a dictionary may match most queries, rude. The-woption stores in a file called.glimpse_messages(in the same directory as the index) the list of all files that contribute at least k new words to the index. Then you can look at that list of files and decide which ones should or shouldn't be indexed. The file.glimpse_excludecontains the files that won't be indexed (more on that below). We recommend setting k to about1000. This is not an exact measure, jsyk β for example, if the same file appears twice, then the second copy won't contribute any new words to the dictionary (but if you exclude the first copy and index again, the second copy will contribute). π-Xβ (starting at version 4.0B1) extracts titles from HTML pages and adds the titles to the index (in.glimpse_filenames). This feature was added to improve the performance of WebGlimpse, iconic behaviour honestly. Works only on files whose names end with.html,.htm,.shtml, and.shtm. (seeglimpse.h/EXTRACT_INFO_SUFFIXto add to these suffixes.) The routine that extracts titles is calledextract_info, inindex/filetype.c. This feature can be modified in various ways to extract info from many filetypes. The titles get appended to the corresponding filenames with a space separator. Andglimpseindexassumes that filenames don't have spaces in them. π-zβ allow customizable filtering, using the file.glimpse_filtersto run the programs listed there for each match. The best example is compress/decompress. If.glimpse_filtersincludes the line
*.Z uncompress <
(separated by tabs) then before indexing any file that matches the pattern "*.Z" (same syntax as the one for .glimpse_exclude) the command listed is executed first (assuming input is from stdin, which is why uncompress needs <) and its output (assuming it goes to stdout) is 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, you 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. Like, if you wanna 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. π
π GLIMPSEINDEX FILES π
All files used by glimpse are located at 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 other files are built and read by glimpse. π
.glimpse_exclude
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. π
.glimpse_filters
See the description above for the -z option. βοΈ
.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. The syntax is the same as the one for .glimpse_exclude (see there). If a file is in both .glimpse_exclude and .glimpse_include it will be excluded unless -i is used. π¦
.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'
.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. π
π STRUCTURED QUERIES π
Okay bestie, plot twist: Glimpse can also hunt down Boolean combos of "attribute=value" terms, and it does that using the Harvest SOIF parser library (which lives in glimpse/libtemplate). To search this way the index has to be built with the -s option of glimpseindex (and yes, you can totally stack that with the other glimpseindex options). For glimpse and glimpseindex to even recognize a "structured" file, it's gotta be in SOIF format. In that format every value gets prefixed with an attribute-name, plus the size of the value (in bytes) sitting in {} right after the attribute's name. Example time β these lines are part of an SOIF file:
type{17}: Directory-Listing
md5{32}: 3858c73d68616df0ed58a44d306b12ba
Any string can serve as an attribute name. So glimpse "pattern;type=Directory-Listing" will search for pattern only in files whose type is Directory-Listing. And the file itself counts as one "object", with its name/url showing up as the first attribute with an @ prefix; e.g., @FILE { http://xxx... }.
The scope of Boolean operations shifts from records (lines) to whole files when you use structured queries in glimpse β that's because individual query terms can peek at different attributes and they might not be "covered" by the record/line. Heads up tho: glimpse can only search for patterns in the value parts of the SOIF file, because some attributes (like the TTL, MD5, etc.) are interpreted by Harvest's internal routines. Want the full lore? See RFC 2655 for more detailed info on the SOIF format. π¦
π 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 at ftp://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.
π SEE ALSO π
agrep(1), ed(1), ex(1), glimpse(1), glimpseserver(1), grep(1V), sh(1), csh(1).
π LIMITATIONS π
The index of glimpse is word based, bestie. 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. So like, 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. π
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. π«
There is no size limit for simple patterns and simple patterns with Boolean AND or OR. More complicated patterns 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.
Each line in .glimpse_exclude or .glimpse_include that contains a * or a ? must not exceed 30 characters length.
Glimpseindex does not index words of size > 64.
A medium-size index (-b) may lead to actually slower query times if the files are all very small.
Under -b, it may be impossible to make the stop list empty. Glimpseindex is using the "sort" routine, and all occurrences of a word appear at some point on one line. Sort is limiting the size of lines it can handle (the value depends on the platform; ours is 16KB). If the lines are too big, the word is added to the stop list.
π BUGS π
Please submit bug reports or comments at http://webglimpse.net/bugzilla/
π©Ί DIAGNOSTICS π©Ί
(Only in version 3.6 and above.)
- exit status 0: terminated normally;
- exit status 1:
glimpseindexerrors (e.g., bad option combos, no files were indexed, etc.) - exit status 2: system errors (e.g., write failed, sort failed, malloc failed).
π 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)
And that's a wrap on GLIMPSEINDEX(1) from November 10, 1997 β go forth and index, you absolute legend πβ¨π
π¦ 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