Unix masters please help newbie on "find" command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unix masters please help newbie on "find" command
# 1  
Old 09-26-2005
Unix masters please help newbie on "find" command

please help me figure out how to do this

I wont lie, this is for a homework problem and I have searched on google for a long time and still can't figure out what to do.

here is the problem

So there's a folder let's say called "bare"
in it, there are 10 dirs with names from "part1" through "part10"

in each part dir
there are many txt files most beginning with a number but some beginning with spm

those beginning with spm are spams and I need to figure out how many spams there are

to find the total number is easy

find . -name 'spm*' | wc

however the next part is hard

somehow I have to find a way to find out how many spam files there are in each part1-part10 dir.

And I can only use one compound command to do it.

I thought about

find . -name 'part*' -exec find . -name 'spm*' | wc

or find . -name 'part*' -exec find -name 'spm*' | wc

or whatever variations of this

all return find incomplete

please someone help

thank you very much
# 2  
Old 09-26-2005
prof provided this hint which I dont really understand but may be of help

the GNU version. In particular, the printf option is very helpful. Google will lead you to some helpful tutorials on find (the GNU verison). To use the GNU version, it is similar to the posting about using grep. In other words, you must either call the GNU version using
/usr/local/GNU/bin/find
or ssh into treebeard.berkeley.edu and use the find command there.
# 3  
Old 09-27-2005
Thread closed due to homework rule violation.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

4. Shell Programming and Scripting

Problem with "find" and "grep" command

I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank). In a first approach I coded: find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt But this doesn't work. I got an error (under Ubuntu): grep:... (5 Replies)
Discussion started by: pstein
5 Replies

5. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Advanced & Expert Users

Command to find the "unix machine type".

Hi all, Just need some help the following scenario, Is there any UNIX command to find the unix machine type (like whether the machine is belongs to Ssun ultra 45 type) like that .. please help me (2 Replies)
Discussion started by: abhisheksunkari
2 Replies

8. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

9. Shell Programming and Scripting

Parse "masters" ip from named.conf

Hi there, Im' trying to make a script to parse the BIND configuration file from my slave DNS server and obtain a certain parameter. The named.conf file has this format: zone "0.170.20.10.in-addr.arpa" { type slave; file "0/./db.0.170.20.10.in-addr.arpa.bak"; allow-notify {... (2 Replies)
Discussion started by: Citricut
2 Replies

10. UNIX for Dummies Questions & Answers

Unix "at" / "Cron" Command New Problem...Need help

Hi All, I am trying to schedule a one time job using the at command with the help of shell script for my project. The shell script should take a parameter as a command line argument from the at command itself. Is it possible to take a command line parameter for a shell script in the command... (3 Replies)
Discussion started by: Mohanraj
3 Replies
Login or Register to Ask a Question