O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching for Patterns in Files - kgrep

This is the Korn shell version of the Unix grep command. The –b option is not supported, and the –i flag causes multi-character expressions to be matched in both all upper-case or all lower-case (kgrep –i AbC test matches AbC, abc, or ABC in test, but not aBc or other permutations). Here are the supported options:

–c display the number of lines that contain the given pattern
–i ignore case of letters during comparison (see above)
–l display only names of files with matching lines once
–n display the output with line numbers
–s do not display error messages
–v display all lines, except those that match the given expression
					#!/bin/ksh
					#
					#      kgrep - Korn Shell grep program
					#
					# Declare default flags
					CFLAG= ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required