searching different multiple directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting searching different multiple directories
# 1  
Old 03-08-2011
searching different multiple directories

Suppose I have 5 different directories in some path .Is it possible to search 5 different directories using find command in one single command line.

I mean something like this:-
find path -type d -name dirname1 dirname2 ..........

pls help
# 2  
Old 03-08-2011
You can supply multiple paths to GNU find and Solaris find (SunOS 5.10)
eg.
Code:
ls -R test/
test/:
dir1  dir2  dir3

test/dir1:
test.txt

test/dir2:
test.txt

test/dir3:
test.txt
~/ $ find test/dir1 test/dir2 -name \*.txt
test/dir1/test.txt
test/dir2/test.txt


Last edited by Skrynesaver; 03-08-2011 at 04:44 AM.. Reason: spellink and test on Solaris
# 3  
Old 03-08-2011
Code:
find path \( -name "dirname1" -o -name "dirname2" -o -name "dirname3" \) -type d

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting multiple directories inside multiple directories

Hi, Very unfamiliar with unix/linux stuff. Our admin is on vacation so, need help very quickly. I have directories (eg 40001, 40002, etc) that each have one subdirectory (01). Each subdir 01 has multiple subdirs (001, 002, 003, etc). They are same in each dir. I need to keep the top and... (7 Replies)
Discussion started by: kkouraus1
7 Replies

2. Shell Programming and Scripting

perform 3 awk commands to multiple files in multiple directories

Hi, I have a directory /home/datasets/ which contains a bunch (720) of subdirectories called hour_1/ hour_2/ etc..etc.. in each of these there is a single text file called (hour_1.txt in hour_1/ , hour_2.txt for hour_2/ etc..etc..) and i would like to do some text processing in them. Each of... (20 Replies)
Discussion started by: amarn
20 Replies

3. Shell Programming and Scripting

Nawk help searching for multiple lines and multiple searches

I use this command to find a search (Nr of active alarms are) and print one line before and 10 lines after the search keywords. nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=1 a=10 s="Nr of active alarms are:" *.log However, I would like to know how to tell it to print... (3 Replies)
Discussion started by: tthach830
3 Replies

4. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

5. Shell Programming and Scripting

searching for a filename in ALL directories

Hi, I am searching for a file named "Backup.txt" but I don't know in which directory it is. Can someone tell me, how I can search recursiv in all directories and subdirectories? thanks (2 Replies)
Discussion started by: ABE2202
2 Replies

6. Shell Programming and Scripting

searching content of files in the current and sub directories

Hi I was wondering why command 2 doesn't work like command 1 below. 1. find . -exec grep "test" '{}' \; -print 2. ls -R | grep "test" I am trying to search "test" from all the files in the current and sub directories. What's wrong with my command 2? Thanks in advance for your help (4 Replies)
Discussion started by: tiger99
4 Replies

7. Shell Programming and Scripting

moving directories to new directories on multiple servers

Hi - I am new to unix scripts...I need to move several directories on multiple servers to new directories. (0 Replies)
Discussion started by: mackdaddy07
0 Replies

8. Shell Programming and Scripting

searching for list of empty directories

Guys I need to write a korn shell script that will search for a list of empty sub-directories in a specific directory and then email a list of these empty directories. Any ideas - apologies, I am new to shell scripting. Thanks (4 Replies)
Discussion started by: man80
4 Replies

9. Shell Programming and Scripting

searching through directories

Please help. I am getting back into UNIX and I need a script that requires me to start in one main directory (call it mydata) and under this directory searches several subdirectories within subdirectories. I need to search each directory to locate *_source and delete files within the directory... (2 Replies)
Discussion started by: MrJaunty
2 Replies

10. Shell Programming and Scripting

Searching multiple files with multiple expressions

I am using a DEC ALPHA running Digital UNIX (formly DEC OSF/1) and ksh. I have a directory with hundreds of files that only share the extension .rpt. I would like to search that directory based on serial number and operation number and only files that meet both requirements to be printed out. I... (6 Replies)
Discussion started by: Anahka
6 Replies
Login or Register to Ask a Question