INDEX

Section: User Commands (1)
Updated: 27 July 1989
Index Return to Main Contents
 

NAME

index - maintain simple databases  

SYNOPSIS

index [ -f filter ] [ -i ] [ -v ] [ database ] [ pattern ]  

DESCRIPTION

Index is used to maintain simple databases such as address lists, lists of books or compact discs, and so on. All databases are stored as simple text files in a single directory. By default, this directory resides in your home directory, and is called .index. You can specify a different path name for the directory by setting the environment variable INDEXDIR to the directory's full path name.

When invoked with no arguments, index will present you with a list of the databases you have, and ask you to select the one you want to work with. To create a new database, simply type the name of a non-existent database to the prompt. The name of an existing database may also be specified on the command line, bypassing this step and going directly to the main menu.  

CREATING A NEW DATABASE

When you specify the name of a non-existent database to the database selection prompt, you will be placed in a text editor to create the database description file. This file is simply a list of the field names for the database, one per line. You may have up to 16 fields in each database. Blank lines may be used for continuation lines in multiple-line fields, such as addresses.

The database is always sorted by the first field. When searching the database, the default is to search all fields for the pattern. To specify that a field should be ignored in searching, you should place an exclamation point (!) in the first position on that line.

When you have created the database description file, save the file and exit the editor. You will then be placed in the main menu, where you can manipulate the database.  

THE MAIN MENU

The main menu is the point from which the database can be manipulated. This menu provides you with several commands:

a
Add a new entry to the database. You will be presented with a list of the fields in a database entry, and allowed to fill them in. As you type, characters are inserted at the current cursor location. The editing commands available are a subset of those provided by the EMACS text editor:
^A
Move the cursor to the beginning of the line.
^B
Move the cursor backward one character.
^D
Delete the character under the cursor.
^E
Move the cursor to the end of the line.
^F
Move the cursor forward one character.
^H
Backspace, deleting the character in front of the cursor. The DEL key also performs this function.
^K
Delete from the cursor position to the end of the line.
^L
Redraw the screen.
<RET>
Pressing RETURN moves to the next line, column one. If you're on the last line, this wraps around to the first line.
^N
Move to the next line, without moving to column one. If you're on the last line, this wraps around to the first line.
^P
Move to the previous line. If you're on the first line, this wraps around to the last line.
<ESC>
Pressing the ESCAPE key tells index that you're done editing the entry. You will be asked whether you want to save the entry in the database. If you say yes, it will be saved. If you say no, the data you just entered will be discarded. If you press RETURN, you will be returned to the editing mode.
f
Find an entry in the database. You will be prompted for a pattern to search for, and then all entries which match the pattern will be displayed, one at a time. The pattern may be any regular expression, as described in ed(1). Case is distinguished unless the -i option was given on the command line. See the description of the ``r'' command for the options available to you with each entry displayed.
r
Read the database entry by entry. Each entry in the database is printed on the screen, along with two numbers indicating the number of entries in the database, and the sequential index number of this entry (e.g., ``123/500''). As each entry is printed, you will be allowed to execute the following commands:
<RET>
Pressing the RETURN key will move to the next database entry.
-
Return to the previous database entry.
d
Delete this entry from the database. You will be prompted to confirm this operation.
e
Edit this database entry. See the description of the main menu ``a'' command for a list of the editing commands available. After you press ESCAPE and indicate whether you wish to save what you have edited, you will be returned to this mode again.
q
Return to the main menu without looking at the rest of the entries.
^L
Redraw the screen.
s
Save any modifications to the database.
q
Save any modifications to the database, and exit index.
x
Exit index without saving the database. If the database has been modified, you will be asked to confirm this operation.
 

SEARCHING FROM THE COMMAND LINE

If a database name and pattern are both specified on the command line, the pattern will be searched for in the database, and any matching entries will be printed on the standard output. Each entry will be printed one field per line, preceded by its field name.

The pattern may be any valid regular expression, as defined by ed(1). Case is significant, unless the -i option is given. To match all entries in the database, use the regular expression ``.'' (matches any character).

By default, index will not print any blank lines in the entry, in order to make the output more readable. By specifying the -v option, you can tell index to print all lines in the entry, even if they have nothing on them.  

FILTERS

If the -f option is specified with the name of a filter, then when a database name and pattern are also given, all matching entries will be sent through the filter program instead of to the standard output.

The first line of output will contain the field names for the database, separated by tabs. Each following line will contain one database entry, with fields separated by tabs. This format is easily dealt with using programs such as awk(1).

As a convenience, filtering programs may be stored in the database directory with a ``.fmt'' extension in their file name. The program is first searched for here (by adding the name extension), and if it is not found, it is then searched for (without the extension) in the standard search path.  

EXAMPLE

The following database description file implements a business phone number list. It allows three lines for the company address, and two lines for electronic mail addresses. The extra fields ``Product'' and ``Keywords'' can be used to provide additional patterns to search for (e.g., you might want to search for all disk vendors). The ``!'' character inhibits searching the title, address, and telephone number for patterns.

Name
!Title
Company
!Address
!
!
!Phone
Electronic Mail

Product
Keywords
 

LIMITATIONS

Each database may have no more than 16 fields.

You may not have more than 64 separate databases.

A database may contain as many entries as you can allocate memory for.  

SEE ALSO

awk(1), ed(1)  

AUTHOR

David A. Curry, Research Institute for Advanced Computer Science


 

Index

NAME
SYNOPSIS
DESCRIPTION
CREATING A NEW DATABASE
THE MAIN MENU
SEARCHING FROM THE COMMAND LINE
FILTERS
EXAMPLE
LIMITATIONS
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 10:51:15 GMT, December 12, 2024