Need help using find or locate with wildcards


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Need help using find or locate with wildcards
# 1  
Old 06-15-2011
Need help using find or locate with wildcards

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
List all files in ~c12100 directory beginning with "BOZO" that end with either "123" or "456"


2. Relevant commands, code, scripts, algorithms:
find or locate commands using [ ] and -o


3. The attempts at a solution (include all code and scripts):
find ~c12100 -type f \( -name "BOZO*" -name "*123" -o -name "*456" \)


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Washtenaw Community College, Ypsilanti, MI, Jim, C121

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

---------- Post updated at 08:46 AM ---------- Previous update was at 08:43 AM ----------

3. The attempts at a solution (include all code and scripts):
find ~c12100 -type f \( -name "BOZO*" -name "*123" -o -name "*456" \)

These are the results I got:

Code:
find: /home/students/cis121/c12100/.elm: Permission denied
find: /home/students/cis121/c12100/.ssh: Permission denied
find: /home/students/cis121/c12100/Mail: Permission denied
find: /home/students/cis121/c12100/cprogs: Permission denied
/home/students/cis121/c12100/culture/art/philpicture456
find: /home/students/cis121/c12100/mail: Permission denied
find: /home/students/cis121/c12100/scripts: Permission denied
find: /home/students/cis121/c12100/mydir: Permission denied
/home/students/cis121/c12100/Band456
find: /home/students/cis121/c12100/save_spec: Permission denied
/home/students/cis121/c12100/BOZOand456
/home/students/cis121/c12100/BOZOhello123
find: /home/students/cis121/c12100/dirT: Permission denied
/home/students/cis121/c12100/Zand456
/home/students/cis121/c12100/^abc456
find: /home/students/cis121/c12100/abc876: Permission denied
find: /home/students/cis121/c12100/chap10: Permission denied
find: /home/students/cis121/c12100/chap11: Permission denied
find: /home/students/cis121/c12100/chap12: Permission denied
find: /home/students/cis121/c12100/chap4: Permission denied
find: /home/students/cis121/c12100/d1: Permission denied
find: /home/students/cis121/c12100/numbs: Permission denied
find: /home/students/cis121/c12100/c_progs: Permission denied
find: /home/students/cis121/c12100/chap6: Permission denied
find: /home/students/cis121/c12100/chap7: Permission denied
find: /home/students/cis121/c12100/chap8: Permission denied
find: /home/students/cis121/c12100/chap9: Permission denied
find: /home/students/cis121/c12100/d121: Permission denied
find: /home/students/cis121/c12100/d2: Permission denied
find: /home/students/cis121/c12100/rainbow: Permission denied
find: /home/students/cis121/c12100/d23: Permission denied
/home/students/cis121/c12100/dir1/file456
/home/students/cis121/c12100/dir1/BOZO456
find: /home/students/cis121/c12100/mynewdir: Permission denied
find: /home/students/cis121/c12100/examdir: Permission denied
/home/students/cis121/c12100/file456
find: /home/students/cis121/c12100/myscripts: Permission denied
find: /home/students/cis121/c12100/house1: Permission denied
find: /home/students/cis121/c12100/house2: Permission denied
find: /home/students/cis121/c12100/myjunk: Permission denied
find: /home/students/cis121/c12100/allmich: Permission denied
find: /home/students/cis121/c12100/tdir: Permission denied
find: /home/students/cis121/c12100/jnehez: Permission denied
find: /home/students/cis121/c12100/newdirjunk: Permission denied
find: /home/students/cis121/c12100/old_stuff: Permission denied
/home/students/cis121/c12100/newfile456
find: /home/students/cis121/c12100/My Documents: Permission denied
find: /home/students/cis121/c12100/ddd: Permission denied
find: /home/students/cis121/c12100/test1234: Permission denied
find: /home/students/cis121/c12100/backup: Permission denied


Last edited by pludi; 06-15-2011 at 02:16 PM..
# 2  
Old 06-15-2011
Code:
 find ~c12100 -type f \( -name "BOZO*123" -o -name "BOZO*456" \)

if you dont want to get the permission denied line, then you have look here

https://www.unix.com/unix-dummies-que...direction.html
# 3  
Old 06-16-2011
Hi,

You require a root access when using the find command.
first login as root using su and then fire the find command.
# 4  
Old 06-16-2011
Why use something as heavyweight as find, it will attempt to go through subdirectories and take ages to return, you could simply do something like the following.
Code:
ls ~c12100/BOZO* | grep -E '(123|456)$'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find command and use of wildcards

greetings, below is the find command i am using for some filesystem maintenance: find /data/Engine \( -type d -name .snapshot -prune -o -type d -wholename "/data/Engine/*/CAE" \ -prune -o -type d -wholename "/data/Engine/*/CAD" -prune -o -name ".*.case" \)\ -mtime +365 -print0 -fls... (5 Replies)
Discussion started by: crimso
5 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Wildcards used in find, ls and grep commands

Platforms : Solaris 10 and RHEL 5.6 I always get double quotes , single quotes and asteriks mixed up for find, ls and grep commands. The below commands retrieve the correct results. But , unders stress , I get all these mixed up :mad: .So, i wanted to get a clear picture. Please check if... (7 Replies)
Discussion started by: John K
7 Replies

3. UNIX for Advanced & Expert Users

Wildcards

These 2 websites do a GREAT job of explaining different types of wildcards. I learned about the categories of characters which I never knew about at all. GNU/Linux Command-Line Tools Guide - Wildcards GREP (1 Reply)
Discussion started by: cokedude
1 Replies

4. Shell Programming and Scripting

Find string in list with wildcards

I need to add code to a shell script to find out if a string matches any item in a list, where the list can contain a wildcard character. For example, if I have the following list: ok_versions="03-02-4, 04-01-*" Then I want to compare a particular string to see if it matches any item in... (11 Replies)
Discussion started by: Johan III
11 Replies

5. UNIX for Dummies Questions & Answers

difference of find,locate and whereis

hi guys, may i know the difference of find,locate and whereis ? (3 Replies)
Discussion started by: cromohawk
3 Replies

6. Shell Programming and Scripting

using find to locate hard and soft links with tar

I am digging for certain types of files in the current directory and all its sub-directories and archiving them with the following code: #! /usr/bin/ksh Archive=`date +%Y_%m_%d_%T` find . -type f \( -name \*\.ksh -o -name \*\.sql -o -name \*\.ini \) -print|xargs tar -cf... (4 Replies)
Discussion started by: manthasirisha
4 Replies

7. UNIX for Dummies Questions & Answers

ls with wildcards

ok, I'm trying to write a script file that lists files with specific elements in the name into a txt file, it looks like this ls s*.dat > file_names.txt can't figure out whats wrong with that line, any ideas? thanks in advance (10 Replies)
Discussion started by: benu302000
10 Replies

8. UNIX for Dummies Questions & Answers

wildcards

when writing a shell script (bourne) and using a unix command like 'ls' is there anything special you need to do to use a wildcard (like *)? (3 Replies)
Discussion started by: benu302000
3 Replies

9. UNIX for Dummies Questions & Answers

Difference between locate and find

I was wondering what the difference was between the two commands, I understand that locate won't search for files with certain permissions set. Are there any others? Thanks (1 Reply)
Discussion started by: camerja1
1 Replies

10. UNIX for Dummies Questions & Answers

Wildcards in VI

I'm trying to delete lines from a large text file using VI. Every line that I am wanting to delete start with 'S' - all others do not. (A list of users) I've tried using * but doesn't seem to like it...any ideas... Doesn't have to be VI - but I'm better with VI than sed/awk. (8 Replies)
Discussion started by: peter.herlihy
8 Replies
Login or Register to Ask a Question