[Index]
grep
Search files or an input stream for lines containing
a text value or matches for a regular expression.
Property Summary
Example Summary
Example 1 |
Search a buffer of text for the word red. |
Property Detail
files
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No, not if an in is provided. |
The files to search.
ignoreCase
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. Default to false. |
Ignore case. If true, the search will be case
insensitive.
in
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No, not if files are provided. |
The input to search.
invert
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. Default to false. |
Invert the search. If true, then only lines that
don't contain a match will be output.
lineNumbers
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. 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
Access | READ_ONLY |
Required | Read Only. |
A count of the number of matched lines.
name
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
A display name for the job.
noFilename
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. 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 By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. 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 By | ELEMENT |
Access | READ_WRITE |
Required | No. If not provided no output will be written |
Where to write output to.
regexp
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No, Text is treated as plain text. |
Treat the text to match as a regular expression.
results
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
A collection for org.oddjob.io.GrepLineResult
beans
to be written to.
text
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | Yes, not if a regexp is provided. |
Text to search for. This is a regular expression
if the regexp property is set to true.
withFilename
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. 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 - 2017