11-09-2007
search& count for the occurence of a word
Greetings,
I need to search and count all the occurences of a word in all the files in a directory.
Any suggestions greatly appreciated.
Thanks
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to count the number of occurence of perticular word from one text file.
Please tell me "less" command is work in ksh or not. If it is not working then instead of that which command will work. :confused: (40 Replies)
Discussion started by: rinku
40 Replies
2. Shell Programming and Scripting
i have a file called file1
cat file1
i am namish
namish lives in India
India and namish both are good.
I want to delete all the occurences of namish in one shot,if i do it with sed i guess all the lines will be deleted containing the pattern.Suggest me any idea without AWK.
Thanks... (6 Replies)
Discussion started by: namishtiwari
6 Replies
3. UNIX for Advanced & Expert Users
Suppose i have data like :-
1,2,3,4,5
a,b,c
x,y,z,t
I want to count the occurence of , (comma) in every line.
Waiting for a solution.:) (1 Reply)
Discussion started by: sumit207
1 Replies
4. UNIX for Dummies Questions & Answers
Suppose i have data like :-
1,2,3,4,5
a,b,c
x,y,z,t
I want to count the occurence of , (comma) in every line.
Waiting for a solution. (5 Replies)
Discussion started by: sumit207
5 Replies
5. Shell Programming and Scripting
suppose i have this line
abs|der|gt|dftnrk|dtre
i want to count the number of "|" in this line..
how can i do that.
plz help:confused: (9 Replies)
Discussion started by: priyanka3006
9 Replies
6. UNIX for Dummies Questions & Answers
In a file I have to count a particular word. like i need apache how many times.
I tried this
$ tr "\011" "\012\012"<foo1 | tr -cd "" |sort\uniq -c
but I got result like this
32 apache
18 dns
12 doctor
Please sugest me (4 Replies)
Discussion started by: pranabrana
4 Replies
7. Shell Programming and Scripting
I have an array as follows:
Space: ABC
Name: def
Age: 22
Type: new
Name: fgh
Age: 34
Type: old
Space: XYZ
Name: pqr
Age: 44
Type: new
:
:
How can I separate the array with elements starting from Space:ABC until Space: XYZ & put them in a different array & so on... (4 Replies)
Discussion started by: deo_kaustubh
4 Replies
8. Shell Programming and Scripting
can i get a simple script for , Count same word which has come many times in single lines & pars
Eg file would be ==
"Thanks heman thanks thanks
Thanks heman
thanks man"
So resullt should be
Thanks = 5
heman=2
man = 1
thanks in advance :)
Please use code tags for code and... (1 Reply)
Discussion started by: heman96
1 Replies
9. Programming
Hello,
I have a programming assignment to count number of occurrences of hours in particular file. Below is the code:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
largest = None
fh = open(fname)
counts = dict()
test = list()
for line in fh:
... (2 Replies)
Discussion started by: infinitydon
2 Replies
mdfind(1) BSD General Commands Manual mdfind(1)
NAME
mdfind -- finds files matching a given query
SYNOPSIS
mdfind [-live] [-count] [-onlyin directory] [-name fileName] query
DESCRIPTION
The mdfind command consults the central metadata store and returns a list of files that match the given metadata query. The query can be a
string or a query expression.
The following options are available:
-0 Prints an ASCII NUL character after each result path. This is useful when used in conjunction with xargs -0.
-live Causes the mdfind command to provide live-updates to the number of files matching the query. When an update causes the query
results to change the number of matches is updated. The find can be cancelled by typing ctrl-C.
-count Causes the mdfind command to output the total number of matches, instead of the path to the matching items.
-onlyin dir
Limit the scope of the search to the directory specified.
-name fileName
Searches for matching file names only.
-literal Force the provided query string to be taken as a literal query string, without interpretation.
-interpret Force the provided query string to be interpreted as if the user had typed the string into the Spotlight menu. For example, the
string "search" would produce the following query string:
(* = search* cdw || kMDItemTextContent = search* cdw)
EXAMPLES
The following examples are shown as given to the shell.
This returns all files with any metadata attribute value matching the string "image":
mdfind image
This returns all files that contain "MyFavoriteAuthor" in the kMDItemAuthor metadata attribute:
mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'"
This returns all files with any metadata attribute value matching the string "skateboard". The find continues to run after gathering the
initial results, providing a count of the number of files that match the query.
mdfind -live skateboard
To get a list of the available attributes for use in constructing queries, see mdimport(1), particularly the -X switch.
SEE ALSO
mdimport(1), mdls(1), mdutil(1), xargs(1)
Mac OS X June 10, 2004 Mac OS X