HP 3000 Manuals

Example Search Tasks [ HP Search/XL User's Guide ] MPE/iX 5.0 Documentation


HP Search/XL User's Guide

Example Search Tasks 

This section provides specific examples of HP Search tasks and shows how
to accomplish them.

Searching One File for One Pattern 

The following example searches a single file, named SALARY.SOURCE, for a
single pattern, EMPLOYEE-SSNO:

     :HPSEARCH "SALARY.SOURCE FOR EMPLOYEE-SSNO" 

Searching Several Files for One Pattern 

HP Search allows you to use the same characters the MPE LISTF command
allows to specify file names.  The following example searches all
the files that begin with D in the group SOURCE for the pattern
EMP-HIRE-DATE:

     :HPSEARCH "D@.SOURCE FOR EMP-HIRE-DATE" 

Searching One File for Several Patterns 

The following example searches a single file, named PARSC, for the four
patterns READ, WRITE, OPEN, and CLOSE:

     :HPSEARCH "PARSC FOR READ WRITE OPEN CLOSE" 

Every line of PARSC that contains one or more of these patterns is
displayed.

Redoing a Search 

Whenever you search files with HP Search, the names of all files searched
are written to a file.  All the patterns searched for are also written to
a file.  By default, the files searched are written to the temporary file
SRCHLOG, and the patterns are written to the temporary file SRCHPAT. You
can use these files to search the same set of files for a different
pattern, or to search a different file for the same patterns.  (See also
the SEARCHLOG and PATTERNLOG options in Chapter 3.)

The following two commands search the same set of files:  all the files
in the groups SOURCE and PUB. The first command searches for the pattern
READ, and the second command searches for the pattern WRITE. The second
command uses the temporary file SRCHLOG to specify the files to search:

     :HPSEARCH "@.SOURCE @.PUB FOR READ" 
     :HPSEARCH "^SRCHLOG FOR WRITE" 

The following two commands search two different files, named INPUT1 and
INPUT2, for the same patterns:  AFTER, BEFORE, and ADVANCING. The second
command uses the temporary file SRCHPAT to specify the pattern:

     :HPSEARCH "INPUT1 FOR AFTER BEFORE ADVANCING" 
     :HPSEARCH "INPUT2 FOR ^SRCHPAT" 

Making the Pattern More Specific or Less Specific 

The following command searches the file named SALARY for the pattern "Nov
1987".  The single quotes are required to inform HP Search that "Nov
1987" is one pattern, rather than two separate patterns:

     :HPSEARCH "SALARY FOR 'Nov 1987'" 

The following command makes the search less specific.  HP Search searches
for the pattern "1987":

     :HPSEARCH "SALARY FOR 1987" 

The following command makes the search more specific.  HP Search searches
for the pattern "(1[6-9]|20) Nov 1987".  This represents the dates 16
November 1987 through 20 November 1987:

     :HPSEARCH "SALARY FOR '(1[6-9]|20) Nov 1987'" 

Sending Output to a File 

You can send the output from HP Search to a file by using the LIST
option.  The following example searches the file DATA for the pattern
HOUR and writes the output to both $STDLIST and the file DATALIST. (Use
the QUIET option to stop output to $STDLIST.) If the file DATALIST
already exists, HP Search prompts you before overwriting it.

     :HPSEARCH "DATA FOR HOUR WITH LIST DATALIST" 

If the file DATALIST already exists, the REPLACE argument of the LIST
option suppresses the prompt.  The following command repeats the previous
search and overwrites DATALIST without prompting you for permission.

     :HPSEARCH "DATA FOR HOUR WITH LIST DATALIST REPLACE" 

Using Indirect Files 

An indirect file is a file that contains a list of files to search, or a
list of patterns to search for.  When using an indirect file, precede its
name with a caret (^).  Each file or pattern name must be on a separate
line.  In the following example, the file FILELIST contains the names of
the files to search.  The pattern HP Search looks for is COUNT.

     :HPSEARCH "^FILELIST FOR COUNT" 

The following example searches the file OUTPUT1 for the patterns listed
in the indirect file PATFILE.

     :HPSEARCH "OUTPUT1 FOR ^PATFILE" 

Using a Command File 

You can use a command file on MPE XL to run HP Search.  The following is
a sample command file:

     PARM A=" " B=" " C=" " D=" " E=" " F=" " G=" " H=" "
     RUN HPSEARCH.PUB.SYS;&
     INFO='"!A" "!B" "!C" "!D" "!E" "!F" "!G" "!H"'

If the command file is named S, the following command searches all the
files in the SOURCE group for FREADDIR:

     :S @.SOURCE FOR FREADDIR 

Changing the HP Search Default Options 

You can use a command file to set your own default HP Search options.
The following command file uses the INDEX option:

     PARM A=" " B=" " C=" " D=" " E=" " F=" " G=" " H=" "
     RUN HPSEARCH.PUB.SYS;&
     INFO='"!A" "!B" "!C" "!D" "!E" "!F" "!G" "!H" WITH INDEX'

If the command file is named SI, the following command searches all the
files in the PUB group for EXIT, and streams a job to update the index
file for all the files in the PUB group:

     :SI @.PUB FOR EXIT 

If you give HP Search conflicting options, the first option specified is
used.  The following command searches the file OUTFILE for ERROR and does
not update the index file for OUTFILE:

     :SI OUTFILE FOR ERROR WITH NOINDEX 

Note that HP Search simply ignores the second occurrence of WITH.

Making Searches Faster for a Set of Files 

The INDEX option can make HP Search significantly faster for 1 or more
files.  See chapter 3 for a description of the INDEX option.  This
example shows how you can use a job to run HP Search and index a set of
files.  The same job can be used to re-index all the files in the set
that have changed.  The following example indexes all the files in
ACCOUNT. A nonsense pattern is used to reduce the amount of work done by
HP Search:

     !JOB INDEX, USER.ACCOUNT;OUTCLASS=LP,1
     !RUN HPSEARCH.PUB.SYS;INFO="@.@ FOR XZQXZQ WITH INDEX"
     !EOJ



MPE/iX 5.0 Documentation