Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ WISH ] Show file permissions in octal format #45

Open
cig0 opened this issue May 26, 2015 · 0 comments
Open

[ WISH ] Show file permissions in octal format #45

cig0 opened this issue May 26, 2015 · 0 comments
Labels

Comments

@cig0
Copy link

cig0 commented May 26, 2015

Hello all,
Longtime ls++ fan here.
If you guys ever have the time I think it would be cool to add octal capabilities to the ls listing like I use with the traditional GNU ls:

...
 664 -rw-rw-r--. 1 msx msx 117K May 25 12:16 Screenshot from 2015-05-25 12:15:58.png
 777 lrwxrwxrwx. 1 msx msx   31 Apr 10 20:32 Soulseek Chat Logs -> /home/@data/Soulseek Chat Logs//
 777 lrwxrwxrwx. 1 msx msx   17 Mar 24 23:42 Stash -> /home/@data/Stash/
 777 lrwxrwxrwx. 1 msx msx   21 Feb 16 14:31 Templates -> /home/@data/Templates/
 664 -rw-rw-r--. 1 msx msx  52K May 18 18:33 TIGO_MFS_Manual Tecnico_v1.odt
 640 -rw-r-----. 1 msx msx  13K May 22 18:22 TIGO.png
 777 lrwxrwxrwx. 1 msx msx   18 Feb 16 14:31 Videos -> /home/@data/Videos/
 664 -rw-rw-r--. 1 msx msx  484 May  5 20:56 VM_GH
 777 lrwxrwxrwx. 1 msx msx   15 Feb 16 14:31 VMs -> /home/@data/VMs/
 640 -rw-r-----. 1 msx msx 988K May  4 00:30 yunrl7fmeiespkovaghp.jpg

To achieve this, I use this beautiful awk command - kudos to its creator:

awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(" %0o ",k);print}'

Like:

/usr/bin/ls -lha --group-directories-first --color -F | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(" %0o ",k);print}'

Cheers

@cig0 cig0 changed the title [ WISH ] Show octal format for file permissions [ WISH ] Show file permissions in octal format May 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants