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.
Key elements are the major window panes running from the top to the bottom of the window:
Displays the current project and the working directory.
Sets up the parameters for each search operation. It also includes buttons for starting and stopping a search operation.
Shows the results of the search in a scrollable window.
Displays the search results in the Program Visualizer.
Field for specifying the replacement text and method of replacement (global versus by instance).
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.
Search allows you to:
Search for expressions, extended expressions, or literals
Specify search-match options:
Case sensitive or case insensitive
Matching or nonmatching
Search all files in a directory tree
Display results of search in a scrolled window
Search for a string (an expression, extended expression, or literal) and replace it with a different string
Recall previous directory, file, and expression entries
Provide integration with the FUSE Editor, Emacs, and the Program Visualizer (display search results across one or more files).
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
You can start the Search tool in several ways:
Use the command line.
If you have CDE installed, use the Search tool icon.
Use the FUSE Control Panel once FUSE is running.
Use the Tools menu from most FUSE tools.
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.
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:
Double click on the Application Manager icon in the CDE Front Panel to display the application group icons.
Double click on the FUSE application group icon to display the icons in the FUSE application group.
Double click on the Search tool icon to start the tool.
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.
Most FUSE tools have a Tools menu. To start a tool, select the tool from the Tools menu.
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.
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:
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.
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. |
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.