- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Numeric versions of file permissions?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 02:26 PM
03-19-2002 02:26 PM
Is there an easy way to get the numeric versions of file permissions rather than the rwxrwxrwx versions. I've done a man of ls but I can't find anything.
TIA, Greg
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 02:30 PM
03-19-2002 02:30 PM
SolutionI've answered this before but it's only about a minute's worth of Perl; viz
#!/usr/bin/perl -w
use strict;
my $i = 0;
while ($i <= $#ARGV)
{
my ($dev,$ino,$mode) = stat($#ARGV[$i]);
printf("%s\t%03o\n",$#ARGV[$i],$mode & 0777);
++$i;
}
That should do it. Use it as fmode.pl file1 ...
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 02:36 PM
03-19-2002 02:36 PM
Re: Numeric versions of file permissions?
# man getaccess
Example:
filename = abc
permission = -rw-r--r--
owner:group = root:bin
# getaccess -n -u skchan abc
4 abc
==> the -n option gives the numerical representation of the permission with reference to user "skchan" in the above example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 03:00 PM
03-19-2002 03:00 PM
Re: Numeric versions of file permissions?
Thanks, Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 03:04 PM
03-19-2002 03:04 PM
Re: Numeric versions of file permissions?
No, it's quite trivial. We simply expand the printf by 1 octal digit and mask off 1 less nibble.
#!/usr/bin/perl -w
use strict;
my $i = 0;
while ($i <= $#ARGV)
{
my ($dev,$ino,$mode) = stat($#ARGV[$i]);
printf("%s\t%04o\n",$#ARGV[$i],$mode & 07777);
++$i;
}
P.S. This also reveals the 'sticky' bit. The 1xxx part.
Regards and learn Perl, Clay