coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A small suggestion to improve ls


From: Pádraig Brady
Subject: Re: A small suggestion to improve ls
Date: Sat, 27 Dec 2014 11:44:25 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 27/12/14 05:05, Sasha Shepherd wrote:
> 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?

We couldn't change the default output format of ls -l at this stage.
Note the symbolic modes could be one of these at least [rwxXst].
Also note that chmod can accept these symbolic modes. chmod a+x etc.
https://www.gnu.org/software/coreutils/manual/html_node/Symbolic-Modes.html
Personally I rarely use numeric modes.

Also note that tools like `find` can be leveraged to display symbolic modes:
  find -maxdepth 1 -printf '%m ' -ls

This is something we might consider adding to ls if we
ever support a --format option, which would give more
flexibility on fields to output.

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]