|
![](/i/fill.gif) |
Orchid XP v8 <voi### [at] dev null> wrote:
> Or rather, I'd rather write my own program than use grep for a *complex*
> search. (E.g., find anything that's a valid XML fragment.)
Don't start making unfair comparisons. 'grep' (as well as other similar
tools such as 'sed') is a line-based tool. It can match individual *lines*
of the input. It cannot be used to perform operations which would require
interpreting several lines (unless it has some non-standard extensions).
Recognizing a valid XML fragment would require interpreting several lines
of the input (if you want to be able to match all possible cases), and hence
'grep' cannot be used for that.
'grep' is most useful for finding things you know are all in one line,
and for filtering files with a known format (such as httpd logs).
If you need more complicated things like that, then often 'awk' or 'perl'
can be used (still usually with shorter commands and faster than writing
your own program would). For example 'perl' can be used for the same things
as 'grep' and 'sed', but it has a vastly expanded set of match patterns and
other instructions.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |