STScI Logo

match system



match -- match a pattern against the lines in a file or files


match pattern files


The pattern to be matched. A pattern may contain any of the pattern matching metacharacters described below.
A template specifying the file or files to be searched. Omitted if the standard input is redirected.
metacharacters = yes
Set to "no" to disable the pattern matching metacharacters, e.g., when you want to explicitly match one of the metacharacters as a regular character.
stop = no
If stop is enabled, lines with match the pattern are "stopped" (not passed to the output), otherwise only those lines with match the pattern are output.
print_file_names = yes
If more than one file is being searched, preface each printed line with the "file_name: ".


The listed files are searched for the given pattern, copying each line that matches to the standard output. If "stop" is set the action is reversed, i.e., all lines are passed on to the output except those which match the pattern. If no files are named text is read from the standard input. The pattern matching metacharacters are described in the table below.

	^		matches the beginning of a line
	$		matches the end of a line
	?		matches any single character
	*		matches zero or more of whatever is at the left
	[12345]		matches any single character in the given set
	[1-5]		matches any single character in a range
	[^a-z]		matches any character NOT in the range/set
	#		matches whitespace
	{chars}		turns off case sensitivity inside the braces
	\		used to include a metacharacter in the pattern

If more than one file is being searched, each output line is prefixed with its file name.


1. From all the lines displayed by "set", print only those that have the string "tty" somewhere in them.

cl> set | match tty

2. Find all tasks that delete something.

cl> help * | match delete

3. Delete all the "red" objects from the list file "catalog".

cl> match red catalog stop+ > newcatalog

4. Type out the file "spool", omitting all lines that end in a colon, and paginating the output.

cl> match ":$" spool stop+ | page


lcase, ucase, translit, sort, unique

Source Code · Search Form · STSDAS