On Thu, Nov 15, 2012 at 5:39 PM, Edward Ned Harvey (lopser) <
[email protected]> wrote:

>  I'm running a script as root, I'm going to parse a file.  I can easily
> test that the file is owned by root.  I want to test if the group or
> other write bit is set.****
>
> ** **
>
> If using "find" you can test that a file is writable by yourself - but not
> test if it's writable by anyone else.
>

Depending on your version of find, you could do either "find /path/file
-mode /022" or (apparently the now deprecated way for the same thing) "...
+022".


> ****
>
> If using "stat" you can get the perms in drwxrwxrws format.  But the
> number of characters sometimes varies, based on whether or not it's a
> character special device, directory, softlink, etc.
>

Mentioned before, but if you're into bash and if your version of stat
supports it:  [[ $(( $(stat -c 0%a /path/file) & 022 )) -ne 0 ]] && echo g
or o writable
_______________________________________________
Tech mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to