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

Did you try using the find utility?

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 .....

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 !

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

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...:cool:

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???:b:

Just wondering why it has to be on one line......?

If i were you , this is what i would do

$ ls -lRt | grep -v Archive
<notice the 'R' , its list RECURSIVE>

or here is another one:

$ for x in `ls -lF | grep '/' | grep -v Archive`;do
echo $x | cut -f 9 | ls -lR
done

summary:
Note: encapsulate the ls -lF ... line within FOR by using tilde [character left of number 1 on standard keyboard]

here i am looping thru all the directories <except archive> and listing there contents

for the curious ls -F gives the list but adds a '/' infront of directory names!

make suitable replacements for names u need.
Let me know if it helps!

-Samarth

$ find . -print
.
./archive
./archive/decisions
./archive/error
./archive/logs
./archive/processed
./archive/results
./config
./decisions
./error
./inbox
./logs
./outbox
./processed
./progress
./results
$ find . \( -name archive -prune \) -o -print
.
./config
./decisions
./error
./inbox
./logs
./outbox
./processed
./progress
./results
$

With zsh:

print -l **/*~archive*

For example:

zsh 4.3.4% mkdir -p archive/results config
zsh 4.3.4% find
.
./archive
./archive/results
./config
zsh 4.3.4% print -l **/*~archive*
config

thanx everybody for your help and co-operations......:slight_smile:

suppose i don't want to traverse progress and decision folder ..how i am going to achieve......thru same line