Re: Counting specific elements in a XML object



On 3/30/06, Hans Meier (John Doe) <security.department@xxxxxxxx> wrote:
Gavin Bowlby am Donnerstag, 30. März 2006 21.45:
How about:

cat fn | grep <string to be searched for> | wc

When I posted a "cat | grep" the first (and last) time, several people got a
well known heart attack :-)

grep <string to be searched for> fn | wc

as a non-Perl approach to the problem...
[...]

Agreed, but OT here ;-)

Hans

If we are going to pick nits then it should be

grep -c "<employee>" fn
.



Relevant Pages

  • Re: Finding files containing string
    ... I thought I would have to cat everything, piping through grep 'string', but that doesn't search recursively, the help-file doesn't show a recursive flag, and I'm not sure that it would actually give me the filenames anyway. ...
    (Fedora)
  • Re: List files containing a string..
    ... Er, the question was about files containing a string, not about file ... got were responses like man grep, ... What is not readily apparent in the xargs man page is that it ... that is the standard one on FreeBSD has a -r/-R option and even ...
    (comp.unix.bsd.freebsd.misc)
  • Looking for text inside files does not work at all
    ... for an ascii text string in a file. ... Hex-editing the file reveals that there is a string called "reloc" right ... So if text search (aka grep) worked, this should work too shouldn't it? ... That's how it worked in Windows 2000. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: grep and dollar sign
    ... >> cat testfile ... > echo $SEARCH ... > There is no output from the grep command when searching for the string ... only treats $ when it appears at the end of the string. ...
    (comp.unix.shell)
  • Re: modifying files using script
    ... specific string with another one. ... This script works well for one file but exits after that. ... so I used fgrep in the example (grep -F may be preferable or required ... as string by fgrep and RE by $editor, ...
    (comp.unix.shell)