.paper size 55,75 .left margin 9 .right margin 75 .spacing 1 .tab stops 9,14,19,24,29,34,39,44,49,54,59,64,69,74 .nofill .center 75 Clinical Computing Facility .skip 2 .center 75 IAS System Documentation .skip 4 .center 75 GREP (Get REPresentation) program .skip 4 .center 75 Version 1.0.0 - March 19, 1981 .skip 29 For additional information, phone or write: .break .left margin 35 Documentation Box 3181 Duke University Medical Center Durham, North Carolina 27710 (919)-684-6804 .page .left margin 9 Version 1.0.0 - March 19, 1981 - Bruce C. Wright .page .fill .justify The GREP program is used to locate all of the occurrances of a given search string in a set of files. By default, all of the lines in all of the files which match the search string are printed out on the user's terminal, although this can be overridden (see below). The program is run by: .skip ####PDS> RUN [11,1]GREP .skip ####or .skip ####PDS> GREP .skip ####if the task is permanently installed. .skip The program prompts with GRE> and expects a command of the form: .skip ####FILESPEC/switches search__string .skip ####or .skip ####LISTFILE_=FILESPEC/switches search__string .skip Both forms are acceptable; if the first form is used the listing of the matched lines will be directed to the user's terminal (unless overridden with a /OUTPUT:listfile switch), while if the second form is used the output will be directed to the LISTFILE specification. The meaning of this is identical with the /OUTPUT:listfile switch described below, and is provided for some compatibility with non-DCL command lines. .skip FILESPEC is the file specification of the files to be searched. This can have generalized wild cards, for example *.PLI, A*.PLI (all of the files starting with A and ending in .PLI), and supports all of the string constructors allowed with the 'search__string' argument. .skip /switches are the modifiers applied to the search. There are currently five switches allowed: .list .list element /COUNT - Print the names of the files which had lines which matched the search__string, and the number of lines which matched, but don't print the matching lines themselves. .list element /EXCEPT - Print all lines in the file EXCEPT those which match the search argument. .list element /FILES - Print just the file names of the files which had lines matching the search argument. If /EXCEPT is specified as well, the sense of /COUNT and /FILES is reversed and only files NOT containing the search argument are printed. .list element /OUTPUT:listfile - Direct the output of GREP to a file rather than the user's terminal. This can be specified as either /OUTPUT:listfile or /OUTPUT_=listfile. .list element /UPPER - Make the comparison without regard for case in both the search__string and the file. .end list The search__string is any string of characters. Leading blanks are ignored; if they are to be included they must be escaped (see below). The following characters have special meaning within a search string: .skip _? - Matches exactly one character. .skip _* - Matches zero or more characters. .skip _^ - Matches the beginning of the line. .skip _$ - Matches the end of the line. .skip _< - Begins an angle bracket list. The list is terminated with a _> character. An angle bracket list matches a single character. Within the list are the valid characters for that position in the record. The '-' character can be used in this context to specify a range of characters; if it is included, all of the characters from the one on the left through the one on the right are valid in that position. For example, an lower case alphabetic character position can be specified as _, and an alphanumeric can be specified as _. Note that these only match lower case alphabetics; to match either case either /UPPER must be specified or the form _ must be used. A more complicated example is the expression to locate all of the device specifications in a file: <0-7>: which finds lines in the files which have two alphabetic characters followed by an octal digit followed by a ':', somewhere within the line. .skip _\ - Escapes the next character from its normal lexical meaning. This allows searches for strings containing _$, _^, _<, _-, _\, _*, _?, and _>. .skip _' - Used to start a string if the string starts with a _', _/, or blank or tab character. In this context it is similar to the use of the _\ character but is used only to signal the start of the string, and is treated as an ordinary character in the middle of the string.