Languages and Scripting

Reg find command for depp directory structure

 
SOLVED
Go to solution
zxcv
Super Advisor

Reg find command for depp directory structure

Hi ,

Am looking for a find command with arguments  that would help me to search fast through a deep dierctory structure .

Am using hpux 11iv2.

 

7 REPLIES 7
Dennis Handly
Acclaimed Contributor

Re: Reg find command for deep directory structure

What are you searching for?  A filename or property?

   find path -name "*foo*"

 

Of contents of files?

   find path -exec fgrep bar {} +

zxcv
Super Advisor

Re: Reg find command for deep directory structure

Hi Dennis ,

Am trying to search a particular directory from /a/b/c/d/e/f/g/h/001/20090131
/a/b/c/d/e/f/g/h/002/20090229
like this to 600 ( i.e form 001 - 600 )
Dennis Handly
Acclaimed Contributor

Re: Reg find command for deep directory structure

>Am trying to search a particular directory from /a/b/c/d/e/f/g/h/001/20090131
>/a/b/c/d/e/f/g/h/002/20090229 like this to 600 (i.e. from 001 - 600)

 

Again, are you search for filenames or file contents?

 

If in /a/b/c/d/e/f/g/h/, you have lots more than all files with ???, you can try [0-6][0-9[0-9].

zxcv
Super Advisor

Re: Reg find command for deep directory structure

Hi Dennis ,

 

 

Let me make it clear ,

We have the folllowing direcrory structure ,

 

/ftp/gb/B2/kv/cations/001  t0 650 clients

 

Now i need to find ONLY all month end directories with its contents i.e 

/ftp/gb/B2/kv/cations/001/reports/20090131

.

.

.

.

.

/ftp/gb/B2/kv/cations/650/reports/20091231

Dennis Handly
Acclaimed Contributor

Re: Reg find command for deep directory structure

>I need to find ONLY all month end directories with its contents

/ftp/gb/B2/kv/cations/001/reports/20090131

/ftp/gb/B2/kv/cations/650/reports/20091231

 

Then you can just use nested Composite patterns:

ls /ftp/gb/B2/kv/cations/*/reports/?(??????31|?????(04|06|09|11)30|????0228)

(In leap years you would have a problem with 0229.)

 

Or you can toss this pattern stuff and use awk to find the last entry for each month.

zxcv
Super Advisor

Re: Reg find command for deep directory structure

Hi Dennis ,

 

When i ran the ls comand , my all branches after locations / *  got merged into one common folder for ex: the directories that got created are 20090131,20090229,20090331 etc.

 

I want it tobe like 001/reports/20090131

                               002/reports/20090229

till                            650/reports/20091130

 

 

Dennis Handly
Acclaimed Contributor
Solution

Re: Reg find command for deep directory structure

>When I ran the ls command, my all branches after locations / *  got merged into one common folder

 

I'm confused.  The ls(1) command just lists what's there and attempts to pick the last day in the month.