How to check if “s” permission bit is set on Linux shell? or Perl?

吃可爱长大的小学妹 提交于 2019-12-02 18:19:21

问题


I am writing some scripts to check if the "s" permission bit is set for a particular file. For example - permissions for my file are as follows-

drwxr-s---

How can I check in bash script or a perl script if that s bit is set or not?


回答1:


If you're using perl, then have a look at perldoc:

-u  File has setuid bit set.
-g  File has setgid bit set.
-k  File has sticky bit set.

So something like:

if (-u $filename) { ... }


来源:https://stackoverflow.com/questions/29083434/how-to-check-if-s-permission-bit-is-set-on-linux-shell-or-perl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!