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 :]
On 12/30/2010 11:34 AM, S Mathias wrote:
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
Simplest would be:
grep -r -c word one two three
which produces:
one/asfcxv:1 one/asf.txt:1 one/dsgsdg.txt:1 two/ergd.txt:1 three/web:1 three/werdf.txt:1 three/qwerb:1
There are other options that will give you more precision, but basically I think that grep will give you what you want.
(If I understodd the question ... )
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.
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.
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? ;-)
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.
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:
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 . -type f -exec cat {} ;|sed -r 's/ /\n/g'|sort|uniq -c ---------------------------------------------- Rodolfo Alcazar Portillo - nospaze@gmail.com otbits.blogspot.com / counter.li.org: #367962 ---------------------------------------------- -VMS is a text-only adventure game. If you win you can use unix. W. Davidson
On Thursday 30 December 2010 23:35:43 Bob McGowan wrote:
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.
And on the CentOS list... ;-)
Best, :-) Marko
On Fri, Dec 31, 2010 at 4:48 AM, Marko Vojinovic vvmarko@gmail.com wrote:
On Thursday 30 December 2010 23:35:43 Bob McGowan wrote:
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-->>
Questions and Answers section of Distrowatch Weekly, Issue 385, 20 December 2010, http://distrowatch.com/weekly.php?issue=20101220, has what you are seeking.