Re: recursively count the words occurrence in the text files

2010-12-31 Thread Camaleón
On Thu, 30 Dec 2010 10:34:59 -0800, S Mathias wrote:

 I just can't google for it:

(...)

Just out of curiosity... why not? :-?

http://www.google.com/search?hl=encomplete=0biw=1280bih=839sa=Xei=WpodTYuiIImi8QORlqXrBQved=0CBYQvwUoAQq=bash+count+word+occurrences+in+filesspell=1

Greetings,

-- 
Camaleón


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/pan.2010.12.31.08.59...@gmail.com



Re: recursively count the words occurrence in the text files

2010-12-31 Thread Andrew McGlashan

Hi,

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
$


find . ! -name output.txt -type f|xargs cat | \
   tr -s ' .,' '\n\n\n'|sort -u | \
   while read x;do find . ! -name output.txt -type f| \
   xargs cat|echo $x: `grep -c $x `;done | \
   tee output.txt

That was fun...  of course, it was a one liner, but I added the 
formatting above for the email ;-)


Cheers

--
Kind Regards
AndrewM

Andrew McGlashan
Broadband Solutions now including VoIP


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4d1db31e.1070...@affinityvision.com.au



recursively count the words occurrence in the text files

2010-12-30 Thread S Mathias
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 :\]


  


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/788911.43739...@web121407.mail.ne1.yahoo.com



Re: recursively count the words occurrence in the text files

2010-12-30 Thread Slicky Johnson
On Thu, 30 Dec 2010 10:34:59 -0800 (PST)
S Mathias smathias1...@yahoo.com 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 :\]

grep or find



-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20101230134440.52dd8...@t61.debian-linux



Re: recursively count the words occurrence in the text files

2010-12-30 Thread Wolodja Wentland
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 Wentlandwolodja.wentl...@ed.ac.uk 
 : :'  :
 `. `'` 4096R/CAF14EFC 
   `-   081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


Re: recursively count the words occurrence in the text files

2010-12-30 Thread Chris Davies
S Mathias smathias1...@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-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/806vu7xpr9@news.roaima.co.uk



Re: recursively count the words occurrence in the text files

2010-12-30 Thread Karl Vogel
 On Thu, 30 Dec 2010 10:34:59 -0800 (PST), 
 S Mathias smathias1...@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{$_}\n;
   }
   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-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20101230213326.cc245b...@kev.msw.wpafb.af.mil