I want to convert the output of ls
to octal permission bits.
I think of the shortest and clearest way to implement that excerise: Let's say that we have as input:
total 1
drwxr----x 1 user2 workers 1024 May 26 22:22 dir
-rwx-wxrw- 2 user2 workers 1024 May 26 22:22 file.txt
our output should be:
741 dir
736 file.txt
drwxr----x
. The serious this-is-how-you-should-do-it-in-practice answers nicely illustrate how trying to disguise homework exercises can backfire. – Gilles 'SO- stop being evil' Apr 23 '14 at 00:47