find all the dirs starting with particular name

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support find all the dirs starting with particular name
# 1  
Old 02-13-2012
find all the dirs starting with particular name

Hi Experts,

I want to find all the dirs , subdirs on the sever which start with "sr".
Can anyone let me know command for the same.

find . -type d -name sr* I tried this but it is not working.

Thanks,
Ajay
# 2  
Old 02-13-2012
try this..

Code:
 
find . -type d -name "sr*"

# 3  
Old 02-13-2012
thanks this checks recursive also ?
i am getting many "Permission denied" msgs how to avoid those...
actually after "sr" there can be any number from 0-9 so i precisely want to list only those which has digits after "sr".

Thanks,
Ajay

Quote:
Originally Posted by itkamaraj
try this..

Code:
 
find . -type d -name "sr*"

# 4  
Old 02-13-2012
it will check recursively.. if you want to restrict for one level or two level, then you need to use -maxdepth.

if you want to look only in your directory, then

Code:
 
ls -lrt | grep "^d" | grep "sr[0-9]"

# 5  
Old 02-14-2012
To avoid permission error messages, use this:

Code:
find . -type d -name "sr*" -print 2>/dev/null

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Looking for command line to find dirs based on size and date

Hi, My first time on this site, please excuse me if I've come to the wrong forum. I'm fairly new to Unix/Linux and hoping you can help me out. I'm looking for a command line that will return a list of directories that are larger than 50M and older than 2 days. I thought it may be... (6 Replies)
Discussion started by: Wisconsingal
6 Replies

2. Shell Programming and Scripting

how to use use /usr/bin/find for 4 digit year dirs only

I have lots of directories in ~/. My diaries are stored in directories in ~/ containing exactly 4 digits. How do I use the /usr/bin/find command to only search my diary directories? So I would like my search to include ~/2009/abc/def and ~/2010/2001/33 but not ~/103/ or ~/20101/ or ~/201/... (2 Replies)
Discussion started by: siegfried
2 Replies

3. UNIX for Dummies Questions & Answers

**HELP** how to do a listing of dirs and all sub dirs only

I am trying to get a listing of ALL directories only under /export (as an example). I can get all the dirs directly under /export but I need any sub dirs under those dirs. I've looked (here and google) but can not find anything that works (4 Replies)
Discussion started by: bbraml
4 Replies

4. Shell Programming and Scripting

Find the starting position in a file

I have a file called "INPUT" which takes the following format MNT-BANK-NUMBERO:006,00:N MNT-100-ACCOUNT-NUMBERO:018,00:N MNT-1000-DESCRIPTIONO:045:C . . . Now i got to find the displacements of the account numbers of each field of a file. For the field MNT-BANK-NUMBERO:006,00:N, the... (4 Replies)
Discussion started by: bobby1015
4 Replies

5. OS X (Apple)

how to find a string in file under multiple level dirs

Hi, i am asking a command to find a string in file(s) from multiple level directory structures. help would be really appreciated. (4 Replies)
Discussion started by: ywu081006
4 Replies

6. Shell Programming and Scripting

Find command and pruning .dirs

I'm sure this has been asked before but I couldn't find it with the search. I have a script that looks for files and then moves to another location for further processing. My problem is I can't seem to prune the .s* directories. It doesn't break anything just wanted a cleaner process. Here... (4 Replies)
Discussion started by: jcalisi
4 Replies

7. Shell Programming and Scripting

Find most recent files in dirs and tar them up?

Hey all.. This should be simple but stoopid here can't get head around it! I have many directories, say 100 each with many files inside. I need a script to traverse through the dirs, find most recent file in each dir and add it to a tar file. I can find the files with something like for... (1 Reply)
Discussion started by: bobdung
1 Replies

8. Shell Programming and Scripting

script find files in two dirs HELP

I have a directory which is /home/mark/files/ , inside this particular I have a bunch of filles (see examples below) TST_SHU_00014460_20090302.txt TST_SHU_00016047_20090302.txt TST_SHU_00007838_20090303.txt TST_SHU_00056485_20090303.txt TST_SHU_00014460_20090303.txt... (2 Replies)
Discussion started by: fierusbentus
2 Replies

9. UNIX for Dummies Questions & Answers

using grep to find a value in current dir and sub dirs?

Hey guys, I would like to find all files which contain "client1.dat". I would like to search from the current directory and all subs and print out all the files that have this. Any help would be greatly appreciated. Thanks much. (10 Replies)
Discussion started by: ecupirate1998
10 Replies

10. Shell Programming and Scripting

find all man dirs and build windex... HELP!

Hi all, My goal is to find all my 'man' dirs in my sw structure and from that create a windex db. I get many new software dirs every week soo I need to rebuild the windex db very often. I've started with this: OS: Solaris 8 #!/bin/bash find /sw/tools -type d -name 'man*' -print ... (3 Replies)
Discussion started by: tonlu
3 Replies
Login or Register to Ask a Question