As it is now, the permissions output by ls -l and the permissions required
by chmod are in totally different formats. This is confusing and creates
unnecessary potential for error.

A few years back on StackOverflow, user miku submitted this fantastic
little tweak on ls:

http://stackoverflow.com/questions/1795976/can-the-unix-list-command-ls-output-numerical-chmod-permissions

try it:

 ls -l | 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}'

Doesn't that look nice? It's very helpful without making the output feel
cluttered, and is much more useful for newer and intermediate users who
have not internalized the correlation between the -rwxrwxr-x and three
digit formats. In fact, it helps to teach this correlation, because when
the three are put side by side like this, it's quite obvious how they
relate to each other.

What if this was the default behaviour of ls -l, exactly as the output of
that command looks?

Cheers,
Sasha Shepherd
Katoomba, Australia

Reply via email to