Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple way..

Status
Not open for further replies.

superstarjpmc

Programmer
Jan 22, 2004
38
US
Can anyone suggest me to devise a script, which achieves the following functionality.

a) Find all Files which has group+ world..write access

eg.
-rw-rw-rw- 1 swnet swnetg 0 Feb 4 13:45 test.file

b) All files/directories whose 'unix group' is owned by 'nobody'. ( 'nobody' is name of unix grp ).

cheers
david
 
Second question first:
Code:
find / -group nobody

Using find, you have to be very specific about all three groups of permissions. For example, if you use
Code:
find . -perm u+r,u+w,u+x
you will get a list of files which have read, write, and execute permissions for only the user/owner and no one else.

Here's a very inefficient way
Code:
find /my_path -ls | sed -e 's/^ *//g' | tr -s ' ' ';' > file_list.txt
for LINE in `cat file_list.txt`; do
    PERM=`echo $LINE | cut -d";" -f3`
    NAME=`echo $LINE | cut -d";" -f11`

    USER=`echo "$PERM" | cut -c2-4`
    GROUP=`echo "$PERM" | cut -c5-7`
    WORLD=`echo "$PERM" | cut -c8-10`

    CHECKGW=`echo "$GROUP" | grep "w" | wc -l`
    CHECKWW=`echo "$WORLD" | grep "w" | wc -l`

    if [ $((CHECKGW + $CHECKWW)) -eq 2 ]; then
        echo "$PERM\t$NAME"
    fi
done

--
-- GhodMode
 
GhodMode, answer to question a):
find / -perm -go+w

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top