[ug-bosug] 'find' -maxdepth alternate

USM Bish bish at airtelbroadband.in
Mon Jan 22 10:57:59 PST 2007


On Tue, Jan 23, 2007 at 12:04:36AM +0530, Ananth Shrinivas wrote:
> >    If you are looking for only maxdepth = 1 then will "ls -l" not do the
> >    job (with awk/sed/grep) ?
> >
> >    For arbitrary depths, there ain't no mystery option. You need perl or
> >    python to do that job :(
> >
> >    Ananth
> >
> >
> >No!! this is bad.  I need to use find as I'll be mixing it with the 
> >-newer option
> 
> Maybe this helps ?
> 
> find /DIR/. \( -type d \! -name . -prune \) -o -type f -print
> 
> Standard Hack. The "." needs to be there after the DIR.
>

Excellent  ! This  seems  a very  good  option, Ananth,  using
'find' alone. Only that the dot  after the dir prefix may give
an output something like:

/tmp/parentdir/./file1 (if you place a . after the /stated/path/)

To get exactly what Anil wants, the following would be nearer,
(valid only if the specific directory tree is known):

$ find /tmp/parentdir/* \( -type d \! -name . -prune \) -o -type f -print


Bish




More information about the ug-bosug mailing list