FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 12-30-2010, 06:15 PM
MR ZenWiz
 
Default recursively count the words occurrence in the text files

On Thu, Dec 30, 2010 at 11:07 AM, Cybe R. Wizard
<cyber_wizard@mindspring.com> wrote:
> On Thu, 30 Dec 2010 13:03:13 -0600
> "Cybe R. Wizard" <cyber_wizard@mindspring.com> wrote:
>
>> On Thu, 30 Dec 2010 20:49:45 +0200
>> Marius Gedminas <marius@pov.lt> wrote:
>>
>> > Sounds a bit like a homework exercise...
>>
>> It could be that we've been doing his homework for weeks.
>
> ...and the Debian list has been doing the same for the exact same
> questions.
>
This is why I frequently answer with what most others consider
obnoxious comments like STFW, RTFM, DYOH (that's Do Your Own Homework)
and the like, or just ignore the postings.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-30-2010, 07:05 PM
Wolodja Wentland
 
Default recursively count the words occurrence in the text files

On Thu, Dec 30, 2010 at 10:34 -0800, S Mathias wrote:
> I just can't google for it:
> I'm searching for a "bash" "one liner" (awk, perl, or anything) for this:
> there are text files, in several directories:
[…]

How do you define a word?
--
.'`. Wolodja Wentland <wolodja.wentland@ed.ac.uk>
: :' :
`. `'` 4096R/CAF14EFC
`- 081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
 
Old 12-30-2010, 07:17 PM
Chris Davies
 
Default recursively count the words occurrence in the text files

S Mathias <smathias1972@yahoo.com> wrote:
> *recursively count the words occurrence in the text files like: "word1 2"
> can anyone point to a howto/link? [re: i just can't google for it :]

What are you actually trying to do? Neither your example nor your
description makes any sense, here.

Are you perhaps trying to count the number of words in a series of files?
wc -l $( find * -type f )

Or something else?

Chris


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 806vu7xpr9.ln2@news.roaima.co.uk">http://lists.debian.org/806vu7xpr9.ln2@news.roaima.co.uk
 
Old 12-30-2010, 08:33 PM
 
Default recursively count the words occurrence in the text files

>> On Thu, 30 Dec 2010 10:34:59 -0800 (PST),
>> S Mathias <smathias1972@yahoo.com> said:

S> ...recursively count the words occurrence in the text files.

This assumes words consist of alphanumeric characters only. If that's
not the case, you'll need to change the "tr/" line in the script.

me% head */*
==> one/asf.txt <==
word1 word2 word3

==> one/asfcxv.txt <==
word2 word4, word5

==> one/dsgsdg.txt <==
word1. word2

==> three/qwerbdsg.txt <==
word7, word8 word9 word10

==> three/weberg.txt <==
word4 word3

==> three/werdf.txt <==
asdf, word2

==> two/ergd.txt <==
word6

==> two/sdgsddsf.txt <==
word6, word3


me% cat words
#!/usr/bin/perl -w
use strict;
my %words;

while (<>) {
tr/a-zA-Z0-9/ /cs;
foreach my $w (split) {
$words{$w}++;
}
}
foreach (sort keys %words) {
print "$_ $words{$_}
";
}
exit(0);


me% ./words */*
asdf 1
word1 2
word10 1
word2 4
word3 3
word4 2
word5 1
word6 2
word7 1
word8 1
word9 1

--
Karl Vogel I don't speak for the USAF or my company
Never take a beer to a job interview. --Martha Stewart's tips for Rednecks


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20101230213326.CC245BFC0@kev.msw.wpafb.af.mil">htt p://lists.debian.org/20101230213326.CC245BFC0@kev.msw.wpafb.af.mil
 
Old 12-30-2010, 09:20 PM
Aaron Konstam
 
Default recursively count the words occurrence in the text files

On Thu, 2010-12-30 at 10:34 -0800, S Mathias wrote:
> I just can't google for it:
>
> I'm searching for a "bash" "one liner" (awk, perl, or anything) for this:
>
Attached is a python program that counts the number of words in a file.
This could easily be slightly altered and combined with find to do what
you want.

--
================================================== =====================
"Plaese porrf raed." -- Prof. Michael O'Longhlin, S.U.N.Y. Purchase
================================================== =====================
Aaron Konstam telephone: (210) 656-0355 e-mail: akonstam@sbcglobal.net
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 12-30-2010, 09:51 PM
Joe Zeff
 
Default recursively count the words occurrence in the text files

On 12/30/2010 02:20 PM, Aaron Konstam wrote:
> On Thu, 2010-12-30 at 10:34 -0800, S Mathias wrote:
>> > I just can't google for it:
>> >
>> > I'm searching for a "bash" "one liner" (awk, perl, or anything) for this:
>> >
> Attached is a python program that counts the number of words in a file.
> This could easily be slightly altered and combined with find to do what
> you want.

Or, if you don't want to reinvent the wheel, you can just use the
standard Unix program, wc.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 12-30-2010, 10:17 PM
Thomas Cameron
 
Default recursively count the words occurrence in the text files

On 12/30/2010 12:34 PM, S Mathias wrote:
> I just can't google for it:
>
> I'm searching for a "bash" "one liner" (awk, perl, or anything) for this:
>
> there are text files, in several directories:
>
> mkdir one
> mkdir two
> mkdir three
>
> echo "word1 word2 word3"> one/asf.txt
> echo "word2 word4, word5"> one/asfcxv saf.txt
> echo "word1. word2"> one/dsgsdg.txt
>
> echo "word6, word3!"> two/sdgsd dsf.txt
> echo "word6"> two/ergd.txt
>
> echo "asdf, word2"> three/werdf.txt
> echo "word7, word8 word9 word10"> three/qwerb erfsdgdsg.txt
> echo "word4 word3"> three/web erg as.txt
>
> so it does the magic* "recursively":
>
> $ SOMEMAGIC> output.txt
> cat output.txt
> asdf 1
> word1 2
> word2 4
> word3 3
> word4 2
> word5 1
> word6 2
> word7 1
> word8 1
> word9 1
> word10 1
> $
>
>
>
> *recursively count the words occurrence in the text files like: "word1 2"
> can anyone point to a howto/link? [re: i just can't google for it :]
>
>
>

Does your prof know you're asking the Fedora community to do your
homework? ;-)
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 12-30-2010, 10:35 PM
Bob McGowan
 
Default recursively count the words occurrence in the text files

On 12/30/2010 03:17 PM, Thomas Cameron wrote:
> On 12/30/2010 12:34 PM, S Mathias wrote:
>> I just can't google for it:
>>
>> I'm searching for a "bash" "one liner" (awk, perl, or anything) for this:
>>
>> there are text files, in several directories:
>>
<<--deleted details-->>
>>
>
> Does your prof know you're asking the Fedora community to do your
> homework? ;-)

He's actually asked the same question on the debian-user list as well.

--
Bob McGowan
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 12-30-2010, 10:53 PM
Jonesy
 
Default recursively count the words occurrence in the text files

On Thu, 30 Dec 2010 11:15:58 -0800, MR ZenWiz wrote:
> On Thu, Dec 30, 2010 at 11:07 AM, Cybe R. Wizard wrote:
>> On Thu, 30 Dec 2010 13:03:13 -0600 "Cybe R. Wizard" wrote:
>>> On Thu, 30 Dec 2010 20:49:45 +0200 Marius Gedminas wrote:
>>>
>>> > Sounds a bit like a homework exercise...
>>>
>>> It could be that we've been doing his homework for weeks.
>>
>> ...and the Debian list has been doing the same for the exact same
>> questions.
>>
> This is why I frequently answer with what most others consider
> obnoxious comments like STFW, RTFM, DYOH (that's Do Your Own Homework)
> and the like, or just ignore the postings.

Speaking as an ex-adjunct professor in "Computer Science", I would urge
folks to answer such homework questions with 400-500 level solutions.
Even the most oblivious instructor in the 100-200 level classes will see
that it is not Original Work.

E.g.;
When it's a 'script' request, offer a convoluted (working) perl solution.

HNY
Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | @ config.com | Jonesy | OS/2
* Killfiling google & XXXXbanter.com: <http://jonz.net/ng.htm>


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-30-2010, 11:51 PM
MR ZenWiz
 
Default recursively count the words occurrence in the text files

On Thu, Dec 30, 2010 at 3:53 PM, Jonesy <gmane@jonz.net> wrote:
> On Thu, 30 Dec 2010 11:15:58 -0800, MR ZenWiz wrote:
>>
>> This is why I frequently answer with what most others consider
>> obnoxious comments like STFW, RTFM, DYOH (that's Do Your Own Homework)
>> and the like, or just ignore the postings.
>
> Speaking as an ex-adjunct professor in "Computer Science", I would urge
> folks to answer such homework questions with 400-500 level solutions.
> Even the most oblivious instructor in the 100-200 level classes will see
> that it is not Original Work.
>
Ooh, that's mean!

I like it.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 02:54 AM.

VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org