[lug] "find" question

Chip Atkinson chip at pupman.com
Tue Aug 17 11:16:41 MDT 2004


There is a -print0 (zero) argument to find which is for dealing with the
space problem.  Maybe that would help you.

Chip

On Tue, 17 Aug 2004, Daniel Webb wrote:

> On Tue, 17 Aug 2004, David Morris wrote:
> 
> > I could be wrong, but it sounds like what you are trying to
> > do is find files in a symbolically linked directory tree
> > which are *not* symbolic links themselves.
> >
> > If that is correct, this is fairly easy to do combined with
> > grep and awk (all one line, but too long for email):
> >
> >     find . -follow -type -f \
> >         -exec ls -l {} \; | grep -v ^l | awk '{print $9}'
> >
> > Or, if you wanted to find *only* symbolic links to files,
> > just drop '-v' from the grep statement and leave everything
> > else the same.
> >
> > Note that while you can put the pipe to grep and awk within
> > the exec statement (which ends with '\;'), though with a bit
> > of difficulty, you don't really want to do that as it'd be
> > much slower.  `ls`, though, must be inside the -exec
> > statement to avoid a command-line that is too long when
> > searching large directory structures.
> 
> That makes sense, although I like my "-follow-dir" addition to find better
> :)
> 
> What if the filenames have spaces in them?  I looked at the documentation
> I have for awk, but didn't see anything for multiple fields.  I thought
> of:
> 
> find . -follow -type -f \
>        -exec ls -l {} \; | grep -v ^l | sed 's/  / /g' \
>        cut --delimiter=' ' --fields=9-
> 
> but that will mess up files with multiple spaces in them.
> 
> Any suggestions for that case?
> 
> Daniel
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> 




More information about the LUG mailing list