File size: 2,843 Bytes
6c50d1f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | <System name="Examples">
<Function name="find">
<!--
Usage: find pattern file
Locates one or more instances of a given pattern in a text file.
All lines in the file that contain the pattern are written to standard output. A
line containing the pattern is written only once, regardless of the number of
times the pattern occurs in it.
The pattern is any sequence of characters whose length does not exceed the
maximum length of a line in the file. To include a blank in the pattern, the
entire pattern must be enclosed in quotes ("). To include a quotation mark in the
pattern, two quotes in a row ("") must be used.
-->
<Input type="arg">
<VarSet name="pattern" when="fileExists">
<Var name="size">
<Value name="empty" property="empty"/>
<Value name="singleChar" property="singleChar"/>
<Value name="manyChars"/>
</Var>
<Var name="quoted">
<Value name="yes" property="quoted"/>
<Value name="no" whenNot="empty"/>
<Value name="unterminated" failure="true"/>
</Var>
<Var name="blanks" whenNot="empty">
<Value name="none"/>
<Value name="one" when="quoted, singleChar"/>
<Value name="many">
<When>
<AllOf property="quoted">
<Not property="singleChar"/>
</AllOf>
</When>
</Value>
</Var>
<Var name="embeddedQuotes" whenNot="empty, singleChar">
<Value name="none"/>
<Value name="one"/>
<Value name="many" once="true"/>
</Var>
</VarSet>
<Var name="fileName">
<Value name="defined" property="fileName"/>
<Value name="missing" failure="true"/>
</Var>
</Input>
<Input type="env">
<VarSet name="file" when="fileName">
<Var name="exists">
<Value name="yes" property="fileExists"/>
<Value name="no" failure="true"/>
</Var>
<VarSet name="contents" when="fileExists" whenNot="empty">
<Var name="linesLongerThanPattern">
<Value name="one" property="matchable" once="true"/>
<Value name="many" property="matchable"/>
<Value name="none" failure="true"/>
</Var>
<Var name="patterns" when="matchable" whenNot="empty">
<Value name="none" once="true"/>
<Value name="one" property="match"/>
<Value name="many" property="match, many"/>
</Var>
<Var name="patternsInLine" when="match">
<Value name="one"/>
<Value name="many" once="true" when="many"/>
</Var>
</VarSet>
</VarSet>
</Input>
</Function>
</System>
|