How to skip symbolic links during "find"

How to skip symbolic links during "find"

Post by Jame » Wed, 28 Jun 2006 05:49:03



Hi all,

I tried to find all files and directories which have been set global
write permission.
ksh on AIX

find / -perm -0002 -ls

However, symbolic links always have perssions "lrwxrwxrwx", therefore
they are
also shown in the result. I could filter them out by piping results
through "grep"
or similiar commands, but I wondered if there is an option to skip
symbolic links
so "find" could be faster.

I checked the man page of find, but I am still confused over the "-H"
option.

"-H         Cause the file information and file type evaluated for each
symbolic link
encountered on the command line to be those of the file referenced by
the link,
and not the link itself. If the referenced file does not exist, the
file information
and type shall be for the link itself. File information for all
symbolic links not on
the command line shall be that of the link itself.
"

Thanks,

James

 
 
 

How to skip symbolic links during "find"

Post by Jeremiah DeWitt Weine » Wed, 28 Jun 2006 06:42:32



> ksh on AIX
> find / -perm -0002 -ls
> However, symbolic links always have perssions "lrwxrwxrwx", therefore
> they are
> also shown in the result.

        Does your 'find' support '-type' and '!'?  You could add
! -type l
to the end of your find command.  (That's the letter ell, not a one.)

Quote:> I checked the man page of find, but I am still confused over the "-H"
> option.

        Don't worry about it for this case.  But what it does, basically, is
use information about the file the link points to, not the link itself.
Kind of like this:

sadalsuud:~$ ln -s /etc/passwd /tmp/foo
sadalsuud:~$ ls -l /tmp/foo ; ls -lL /tmp/foo
lrwxrwxrwx  1 jdw users 11 2006-06-26 17:36 /tmp/foo -> /etc/passwd
-rw-r--r--  1 root root 830 2005-09-14 19:31 /tmp/foo

--
Oh to have a lodge in some vast wilderness.  Where rumors of oppression
and deceit, of unsuccessful and successful wars may never reach me
anymore.  
        -- William Cowper

 
 
 

How to skip symbolic links during "find"

Post by Kevin Collin » Wed, 28 Jun 2006 06:52:40



> Hi all,

> I tried to find all files and directories which have been set global
> write permission.
> ksh on AIX

> find / -perm -0002 -ls

> However, symbolic links always have perssions "lrwxrwxrwx", therefore
> they are
> also shown in the result. I could filter them out by piping results
> through "grep"
> or similiar commands, but I wondered if there is an option to skip
> symbolic links
> so "find" could be faster.

> I checked the man page of find, but I am still confused over the "-H"
> option.

> "-H    Cause the file information and file type evaluated for each
> symbolic link
> encountered on the command line to be those of the file referenced by
> the link,
> and not the link itself. If the referenced file does not exist, the
> file information
> and type shall be for the link itself. File information for all
> symbolic links not on
> the command line shall be that of the link itself.
> "

Try:

 find / ! -type l -perm -0002 -ls

The "! -type l" says "not of type symbolic-link"...

Kevin

--
Unix Guy Consulting, LLC
Unix and Linux Automation, Shell, Perl and CGI scripting
http://www.unix-guy.com