how to find some dir


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to find some dir
# 1  
Old 09-13-2007
how to find some dir

hi everybody,

i have dir structure like this,

.
./processed
./results
./archive
./archive/processed
./archive/results
./archive/logs
./archive/decisions
./archive/error
./logs
./inbox
./decisions
./progress
./outbox
./config
./error

Now my concerns is to search all the files coming under all the dir(s)/sub-dir(s) except the dir(s) and sub-dir
(s) belongs to archive which are 1days back..........i.e. i should not include those files coming under archive dir and sub-dir
# 2  
Old 09-13-2007
Did you try using the find utility?
# 3  
Old 09-14-2007
i tried to use find........in that case i can able to remove only the sub-dir(s) coming under archive, but i cann't totally omit archive itself.......


i am using the following one to find out the dirs not having sub branch,
find . \( ! -name . -prune \) -print


any help if i missed out the find command would appreciated .....
# 4  
Old 09-14-2007
visit "man find"

find . -type d -name "Your Directory name" -print

This command will find the "directory name" in the current loaction.
Current location is denoted by '.' and you can give another path of directory.
You can go down to no. of depths in a directory structure, but you have to manually specify that in above find command.

Thanks !
# 5  
Old 09-14-2007
find problem

you could think about creating a list of the dirs you *do* want to use find on by doing something like.....(in a script by the way)

export dirs=`ls | grep -v archive`

for dir in $dirs ; do
find $dir -print
done

if you dont want to return dirs in the find....

for dir in $dirs ; do
find $dir ! -type d -print
done
# 6  
Old 09-17-2007
Tools

Quote:
Originally Posted by varungupta
visit "man find"

find . -type d -name "Your Directory name" -print

This command will find the "directory name" in the current loaction.
Current location is denoted by '.' and you can give another path of directory.
You can go down to no. of depths in a directory structure, but you have to manually specify that in above find command.

Thanks !
Hi Varun,

thankx a lot.......I think u have not gone thru the the que properly.....
by giving find . -type d , it will list all the dir under your current dir, also if some sub directories are there...

but my query : is there any find command thru which i can list all the directory who doesn't have child dir i.e. sub directories.....?????

here in my case i should loop thru all the folder mentioned in my original posted one except archive folder.....

hopes u are clear mate...Smilie
# 7  
Old 09-17-2007
Quote:
Originally Posted by ajcannon
you could think about creating a list of the dirs you *do* want to use find on by doing something like.....(in a script by the way)

export dirs=`ls | grep -v archive`

for dir in $dirs ; do
find $dir -print
done

if you dont want to return dirs in the find....

for dir in $dirs ; do
find $dir ! -type d -print
done

Hey ajcannon,

you suggestion is my last option, but i am wondering is there any find or anything else command thru which i can achieve the question.....if so kindly suggest which will reduce into one single command line???
Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find directory immediately after the pattern dir name

Hi, From below directories path I need the directory which comes immediately after the "DataPath" /var/errors/LogDefaultPath/DataPath/Data01/Data02 (Directory name "Data01" is the result from this path) /var/errors/LogDefaultPath/DataPath/Log01/Log0202 (Directory name "Log01" is the... (4 Replies)
Discussion started by: Yuvaan12
4 Replies

2. Shell Programming and Scripting

KSH - Find paths of multiple files in CC (dir and sub-dir))

Dear Members, I have a list of xml files like abc.xml.table prq.xml.table ... .. . in a txt file. Now I have to search the file(s) in all directories and sub-directories and print the full path of file in a output txt file. Please help me with the script or command to do so. ... (11 Replies)
Discussion started by: Yoodit
11 Replies

3. Shell Programming and Scripting

what is the find command to find exact dir from the root

I want to find a dir called STOP from the root.so what is the find command. Thanks & Regards Rajkumar (1 Reply)
Discussion started by: rajkumar_g
1 Replies

4. Shell Programming and Scripting

Find ,replace and overwrite from master and sub dir

Hello experts, Can someone please help me handling the below situation. I have files in multiple directories as below. /data/input/A.txt /data/input/a1.txt /data/input/adhoc/b.txt /data/input/adhoc/b1.txt /data/input/adhoc/temp/c.txt /data/input/adhoc/temp/d.txt where some of... (3 Replies)
Discussion started by: pasupuleti81
3 Replies

5. Shell Programming and Scripting

A script to find dir, delete files in, and then del dir?

Hello!! I have directories from 2008, with files in them. I want to create a script that will find the directoried from 2008 (example directory: drwxr-xr-x 2 isplan users 1024 Nov 21 2008 FILES_112108), delete the files within those directories and then delete the directories... (3 Replies)
Discussion started by: bigben1220
3 Replies

6. UNIX for Dummies Questions & Answers

How do I ignore certain dir while using find? solved.

Hello everyone, I'm a newbie. I've got a problem while using find. I know there is a way to do it in man find which is something like find . -wholename './src/emacs' -prune -o -print it works but i also want to use -daystart, -mtime, -type on it and i dont know whats the sequence of these... (0 Replies)
Discussion started by: aquaraider
0 Replies

7. Shell Programming and Scripting

Find /Dir

Here is the problem i now have. i have a list of directories like this W9888 W9848 W9752 W9748 W9683 W9680 W9674 W9558 W9366 i need to scan through those directories and bring back a similar list, except only of the directories not containing subdirectories called "ebooks" or... (4 Replies)
Discussion started by: Movomito
4 Replies

8. UNIX for Dummies Questions & Answers

find and remove last week dir

hello all, I want to ask, how to find last week directory and then remove it.. I have a directory in path /home/backup/ and, inside backup dir, I have 6 dir : - 01_20080414 ( today date ) - 02_20080414 ( today date ) - 01_20080413 - 02_20080413 - 01_20080407 ( last week date ) -... (1 Reply)
Discussion started by: kunimi
1 Replies

9. UNIX for Dummies Questions & Answers

Find and purge a files in a dir

HI All, I have recuirement to purge the files in a directory . In that directory i an having many sub-directory . When i use find command like find ~/work/test/insert -name "*.*" -mtime +12 it is listing the file not accesed before 12 , It also takes the subdirectories inside the... (7 Replies)
Discussion started by: arunkumar_mca
7 Replies

10. Programming

To find a existence of a dir within a dir

Hi, I want to find whether a dir "temp" is present inside a dir. It should get a dir a input and search recursively within that directory to check whether temp is present and return 1 or return 0 if it is not present anywhere inside the directory/sub-directory. I know we can use readdir in the... (1 Reply)
Discussion started by: spsenthil
1 Replies
Login or Register to Ask a Question