[Contents] [Prev. Chapter] [Next Section] [Next Chapter] [Index] [Help]

20    Search

This chapter provides an overview of the Search tool's features and capabilities. For more detailed information on how to use this tool, choose Help: On Search. You can print Help topics using the HyperHelp Viewer.

Search combines all the functionality provided by the UNIX tools grep, fgrep, and egrep, and offers integration with the FUSE environment through a graphical user interface. It allows you to search one or more files for a regular expression or string. In addition, Search allows you to search for a string and replace it with a new string.

Figure Figure 20-1 shows the Search main window.

Figure 20-1:  Search Main Window

Key elements are the major window panes running from the top to the bottom of the window:

Configuration area

Displays the current project and the working directory.

Search definition/activation area

Sets up the parameters for each search operation. It also includes buttons for starting and stopping a search operation.

Result display area

Shows the results of the search in a scrollable window.

Visualize button

Displays the search results in the Program Visualizer.

Replace definition area

Field for specifying the replacement text and method of replacement (global versus by instance).

Information area

Displays information messages and Quick Help on some menu items when you press and hold MB1 on the item.

The files used as the basis for the search may reside in any user-specified directory or directory tree. You can use wildcard characters both to supplement the expression to be matched (extended expressions) and as part of the file/directory location used in the search.

You can also use Search in conjunction with the FUSE Editor. The interoperation between the two tools makes it possible to perform a search, load a file containing the search string into an editor buffer, annotate the lines matching the search string, and work on the file. In addition, you can search for a string and replace it with a new string.


[Contents] [Prev. Chapter] [Next Section] [Next Chapter] [Index] [Help]

20.1    Summary of Features

Search allows you to:


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.2    Requirements for Using Search

Search assumes that the following system utilities are present in your user-defined path:

        grep
        egrep
        fgrep
        sed
        ls
        test
        sh
        find
        awk

In short, this means that you must be able to execute each of the previous utilities in command-line mode, without having to specify a relative pathname. For example:

% grep fopen /usr/include/*.h


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.3    Starting the Search Tool

You can start the Search tool in several ways:


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.3.1    Use the Command Line

You can start the Search tool from the command line using the following command:

% fusesearch [Xt-options] [-cwd]

See Appendix Appendix D and the specific reference pages for the command syntax and options.

If the Control Panel is not running, it starts automatically as a minimized icon. If FUSE is already running, the Search tool is placed in the current project.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.3.2    Use the Search Tool Icon from CDE

When you have CDE installed, FUSE provides a FUSE application group icon and icons for the individual tools that make up the FUSE environment.

To invoke the Search tool:

  1. Double click on the Application Manager icon in the CDE Front Panel to display the application group icons.

  2. Double click on the FUSE application group icon to display the icons in the FUSE application group.

  3. Double click on the Search tool icon to start the tool.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.3.3    Use the FUSE Control Panel

To start Search from the FUSE Control Panel, Select Search from the Tools menu in the Control Panel. FUSE first lists the tool in the Control Panel under the current project. Then the tool main window appears.

Like all tools, Search inherits its working directory from that set for the current project.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.3.4    Use the Tools Menu from Most FUSE Tools

Most FUSE tools have a Tools menu. To start a tool, select the tool from the Tools menu.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.4    Setting Up Search

The working directory is all that Search needs to start. By default, the working directory is the directory set for the current project. Search also uses this directory as the base directory for all search operations, unless otherwise instructed. Section Section 20.5 describes how to search a directory other than the working directory for the project.

If you change the search directory to one that is different from the working directory for the project, you can reset the search directory to the project working directory by clicking on the Reset button.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.5    Executing a Search

To perform a search operation:

Step Action

1

Check that the current search directory setting is correct (see Section Section 20.4). You can edit the Search directory field directly. You can use the Reset button to set the Search Directory field to the value of the current working directory. This also resets the other fields in the find definition/activation area to their default states. If you press MB3 in the Search Directory field, Search displays a list of previous entries for the field.

2

Click on the Match: options box and choose the type of search operation that you want to perform. The Match selection determines whether Search interprets your Search For entry as:

  • A literal, in which case Search invokes the fgrep utility

  • A regular expression, in which case Search invokes the grep utility.

  • An extended regular expression, in which case Search invokes the egrep utility.

For detailed information on these utilities, choose the On Grep option from the Help menu.

3

In the Files field, enter the files you want to search. Separate each file with a space.

4

In the Search For field, enter the string you want to search for.

5

Click on Issue to start the search.

The results of the search operation are shown in the results display area. For the sake of legibility, you can use the options in the Buffer menu to collapse or expand this display. Alternatively, you can double click on a file pathname or on the banner to collapse or expand information. For example, if a list is in the collapsed state and you double click on the file pathname, Search explodes the list to reveal all the lines in the file that match the search string or expression.


[Contents] [Prev. Chapter] [Prev. Section] [Next Section] [Next Chapter] [Index] [Help]

20.6    Replacing Strings

Search allows you to replace strings found in a search query with another string. To perform a replace operation, you must first perform a search operation. After you perform the search operation, do the following:

Step Action

1

In the Results display area, select the item on which the replace operation will be performed. The type of item you select determines how the replace operation performs. For example, if you select a file name, the replace operation replaces all occurrences of the search string found in that file with the replacement string. See the online help for a description of how the replace operation performs for the different types of items within the Results area.

2

In the Replace With field, enter the replacement string.

3

Turn on or turn off the Confirm Replace toggle button. If the toggle button is on, Search invokes an editor to perform the replace operation and you must confirm every replace. If the toggle button is off, Search performs the replace operation and you do not have to confirm each replacement.

4

Click on Replace.


[Contents] [Prev. Chapter] [Prev. Section] [Next Chapter] [Index] [Help]

20.7    Integration with Other Tools

The ability to interoperate with the editors enhances Search's string retrieval capabilities. To load a file into your current editor, double click on a line in the result display area. FUSE loads the file containing the line into a buffer and annotates the line on which you double clicked (FUSE Editor and Emacs only). Each time you click on a different line in the result display area, FUSE switches the annotation symbol to the corresponding line in the editor buffer.

At this point, you can edit the file, using all the functionality normally associated with your editor.

You can display the results of a Search operation in the Program Visualizer by clicking on the Visualize button below the search results display. The Program Visualizer highlights each occurrence of the search string in its display.


[Contents] [Prev. Chapter] [Prev. Section] [Next Chapter] [Index] [Help]