Getting file pemissions
I have to admit it, I’m usually a little lazy so I prefer to have a bunch of scripts ready to work for me located at ~/bin
. The following Perl scripts is one of them, it has been with me for years now:
#!/usr/bin/env perl
use Fcntl ':mode';
foreach(@ARGV){
if (($dev,$ino,$mode) = lstat($_)) {
$permissions = sprintf "%04o", S_IMODE($mode);
printf("$_: $permissions\n");
}
}
For example, if you run it against your $HOME
directory, you’ll get something like this:
$ lsmod.pl $HOME
/home/username: 0755