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.
