[Index]

grep


Search files or an input stream for lines containing a text value or matches for a regular expression.

Property Summary

files The files to search.
ignoreCase Ignore case.
in The input to search.
invert Invert the search.
lineNumbers Prefix output with line numbers.
matchedLineCount A count of the number of matched lines.
name A display name for the job.
noFilename Don't prefix output with a file name.
noPath Remove the path from the file name.
out Where to write output to.
regexp A regular expression to match.
results A collection for org.oddjob.io.GrepLineResult beans to be written to.
text Text to search for.
withFilename Prefix output with a file name.

Example Summary

Example 1 Search a buffer of text for the word red.

Property Detail

files

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo, not if an in is provided.

The files to search.

ignoreCase

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo. Default to false.

Ignore case. If true, the search will be case insensitive.

in

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo, not if files are provided.

The input to search.

invert

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo. Default to false.

Invert the search. If true, then only lines that don't contain a match will be output.

lineNumbers

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo. Default to false.

Prefix output with line numbers. If true then the number of the match in the file or input will be prepended to each line of output.

matchedLineCount

AccessREAD_ONLY
RequiredRead Only.

A count of the number of matched lines.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A display name for the job.

noFilename

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo. Default to false.

Don't prefix output with a file name. If true then no file name will be prefixed to each line of output.

noPath

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo. Default to false.

Remove the path from the file name. If true and a file name is prefixed to each line of output, then the path is removed.

out

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo. If not provided no output will be written

Where to write output to.

regexp

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, not if text is provided.

A regular expression to match.

results

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

A collection for org.oddjob.io.GrepLineResult beans to be written to.

text

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, not if a regexp is provided.

Text to search for.

withFilename

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo. Default to false.

Prefix output with a file name. If true then the file name will be prefixed to each line of output. By default the file name is not prefixed to a single file, only when there are multiple files being searched. This property will prefix the file name when only a single file is being searched.


Examples

Example 1

Search a buffer of text for the word red. In this example the search is case insensitive and the results a written to the console with the line number.

<oddjob>
    <job>
        <grep ignoreCase="true" lineNumbers="true" text="red">
            <in>
                <buffer>5 green cars.
2 red buses.
1 RED lorry.
</buffer>
            </in>
            <out>
                <stdout/>
            </out>
        </grep>
    </job>
</oddjob>


(c) Rob Gordon 2005 - 2013