SEARCHcommand finds text strings in files and displays any lines it finds that match the text string. Two arguments are used: the filenames to be searched and the text strings to be found; wildcards and lists of files can be used to search multiple files, and several text strings can be simultaneously matched--each string is separated by a comma. For example, to find the string "AGN" in all TEX source files in the current directory, you could use the command:
$ SEARCH *.TEX AGNIf you wanted to look for complex strings with embedded blanks, you need to use quotes. The /
WINDOWqualifier specifies the number of lines to be displayed before and after the text string. For example:
$ SEARCH *.TXT "WEEKLY REPORT 12" /WINDOW=(2,1)Instead of having the text lines in which the strings are found displayed to your screen, you may want to save the results in an output file. You can do this using the
/OUTPUTqualifier. For example:
$ SEARCH/OUTPUT=RESULTS.TXT *.TEX Weekly,MonthlyA number of other qualifiers are available to help you restrict your search, for example, by file owner or file creation date. Information about these features are available in the online help files by typing:
$ HELP SEARCHA simple example of how the
SEARCHcommand could be used is shown in Figure 4.9.
DIFFERENCEcommand can be used to compare two files and find lines that do not match. This can be especially useful, for example, for finding out what changes were made between two versions of the same file. While
DIFFERENCEusually expects two filenames on the command line, by specifying only one, the program compares the two highest versions with the same file name.
You can save the output from
DIFFERENCE to a file by using the
/OUTPUT qualifier. You can either specify a filename in which differences should be saved, or the program uses the rootname of the first file being compared and appends a file type of .
DIF. The following example shows how to use the command, saving results in a file called
$ DIFFERENCE/OUTPUT=OUT.DIF FILE1.TXT FILE2.TXTOptions are also available to have the program display the files side by side, in hexadecimal format, to search only a limited number of lines, to include line numbers or change bars in the output, and other functions. These options and the qualifiers used to enable them are described in the online help.
Figure 4.10 shows an example of how the
DIFFERENCE command can be used to compare two text files.
Figure 4.10: Comparing Two Files with DIFFERENCE
Generated with CERN WebMaker