Loading…
Re-coding the ls command, options included — far deeper than it looks.
Everyone types ls several times a day. Re-coding it forces you to understand how the system describes a file: its size, its permissions, its owner, its date. And to discover that the aligned column display, which you took for cosmetics, is a genuine little algorithmic problem.
An ls clone with the -l, -R, -d, -t and -r options: directory reading through opendir/readdir, stat calls, resolving user and group identifiers through getpwuid/getgrgid, alphabetical or date sorting (and its reverse) and size column alignment.
READING SOURCE…