If I have a xml file like the following:
?xml version='1.0'?
employee
nameJohn Doe/name
age43/age
sexM/sex
departmentRecieving/department
/employee
employee
nameBob Gordon/name
age50/age
sexM/sex
departmentShipping/department
Dave Adams am Donnerstag, 30. März 2006 21.12:
If I have a xml file like the following:
?xml version='1.0'?
employee
nameJohn Doe/name
age43/age
sexM/sex
departmentRecieving/department
/employee
employee
nameBob Gordon/name
age50/age
How about:
cat fn | grep string to be searched for | wc
as a non-Perl approach to the problem...
-Original Message-
From: Hans Meier (John Doe) [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 30, 2006 11:38 AM
To: beginners@perl.org
Subject: Re: Counting specific elements in a XML
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...
On 3/30/06, Hans Meier (John Doe) [EMAIL PROTECTED] 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
Chas Owens am Donnerstag, 30. März 2006 22.35:
cat fn | grep string to be searched for | wc
[...]
grep string to be searched for fn | wc
[...]
If we are going to pick nits then it should be
grep -c employee fn
too much work.
c employee fn
But your alias may be different ;-)
Hans
--
Chas Owens wrote:
If we are going to pick nits then it should be
grep -c employee fn
Note that grep -c counts matching *lines*. There is no formal
requirement that these elements appear on separate lines.
Here's a slightly more complex Perl one-liner that counts *occurences*
perl -lne
Bob Showalter am Donnerstag, 30. März 2006 23.32:
Chas Owens wrote:
If we are going to pick nits then it should be
grep -c employee fn
Note that grep -c counts matching *lines*. There is no formal
requirement that these elements appear on separate lines.
Dave,
my first one-liner