# %xgrep-com(5)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

%xgrep-com - Grep command line

## SYNOPSIS

%xgrep-com "string"; Default is "`grep` "

## DESCRIPTION

Sets the command line used to execute a grep(1) system command. The output of the xgrep(3) execution should include both file and line number information so that the command get-next-line(2) can be used properly. This is not defined by default and the xgrep command will not execute until it is defined.

grep(1) is typically used with the -n option which produced line numbering information which drives the get-next-line(2) command.

## EXAMPLE

The following example shows how the xgrep strings are defined.

    set-variable %xgrep-com "grep -n "
    0 add-next-line "*grep*"
    add-next-line "*grep*" "%f:%l:"

This definition corresponds to a grep output such as:-

    m5var000.5:13:Sets the  number of seconds to wait
    m5var000.5:14:temporary file to t seconds. A
    m5var000.5:15:Note than the  temporary
    m5var000.5:17:saving a buffer.  Backup  files are
    m5var000.5:24:On unlimited  length  file  name  systems

where grep produces file and line number information for every match.

Use add-next-line(2) to define the line pattern produced by grep. Some versions of grep place the file name on a single line matches within the file occur on subsequent lines. In this case additional add-next-line patterns may be defined to cater for the grep output as follows:

    set-variable %xgrep-com "grep /n "
    0 add-next-line "*grep*"
    add-next-line "*grep*" "File: %f:"
    add-next-line "*grep*" "%l:"

This definition would be used with a grep output such as:-

    File:m5var000.5:
    13:Sets the  number of seconds to wait
    14:temporary file to t seconds. A
    15:Note than the  temporary
    17:saving a buffer.  Backup  files are
    24:On unlimited  length  file  name  systems
    File:m5var001.5:

## NOTES

grep(1) is a standard utility on UNIX systems. For Windows 95/NT a version of GNU grep may be found at:

<ftp.winsite.com/ftp/pub/pc/winnt/misc/gnugrep.zip>

For MS-DOS users, a DJGPP port of grep is also available on the net. A commercial version of grep is also available from MKS.

The MicroEmacs 2009 built in grep(3) provides similar functionality and does not rely on an external program.

## SEE ALSO

add-next-line(2), grep(1), grep(3), xgrep(3), rgrep(3), add-next-line(2).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/31
Generated On: 2009/10/12

</HMTL>