3 ms·
> No, ls has dozens of tangled options because the philosophy is to "do one thing and do it well". Do you mean that in order to truly do well its one thing (li
by telemachos 14y ago
> No, ls has dozens of tangled options because the philosophy is to "do one thing and do it well".
Do you mean that in order to truly do well its one thing (list information about files), that ls had to incorporate things like these?
-o List in long format, but omit the group id.
-T When used with the -l (lowercase letter ``ell'') option, display complete
time information for the file, including month, day, hour, minute, second,
and year.
-x The same as -C, except that the multi-column output is produced with entries
sorted across, rather than down, the columns.
Some degree of feature creep is probably inevitable, but a lot of the common utilities now seem to lean towards "offer a flag for everything" rather than "do a small number of permutations on one thing; create pipelines for the rest". (Note: These three options are all from OSX's BSD-derived ls. GNU's version is almost certainly more complex still.)
- masklinn 14y ago> that ls had to incorporate things like these? Or this bunch: -p Write a slash (`/') after each filename if that file is a directory. -r Reverse the order of the sort to get reverse lexicographical order or the oldest entries first (or largest files last, if combined with sort by size -S Sort files by size * -p's information is redundant with the first character of the long format * -S (and -r) are redundant with `sort` (ls -lSr -> ls -l | sort -k5; ls -lS -> ls -l | sort -rk5)
- lmm 14y ago-p is immensely useful. Of course it's redundant in long format; it's for using in short format. -r is also very useful (I use -tr all the time, which I can't immediately see how I'd replace with sort), and while I could replace ls -lS with piping into sort, you seem to be assuming ls will always be outputting one file per line, which is far from its most useful output mode when running it in a terminal.
- masklinn 14y ago> you seem to be assuming ls will always be outputting one file per line No, I am assuming a "do one thing" `ls` would be used in long format (or as inode numbers) whenever it need to be worked with, and would be massaged into form by further commands. For `t`, `r`, `S` and a bunch of others you'd ls, sort and then cut/awk/whatever to format into a "short form". Not that it matters a bit. Also, I didn't claim these weren't useful, I claimed they were redundant. Which they are.
- access_denied 14y agoYes. It would be a regexp nightmare to sort ls output if you got it one way and then wanted to format it a certain way.
- sp332 14y ago-o is probably for compatibility with some other system. -T seems useful doesn't it? How else would you get that info? And -x is a personal preference. None of those seem especially useless.
- telemachos 14y ago> -T seems useful doesn't it? How else would you get that info? The long (-l) format already provides the month, day, hour and minutes. -T adds only seconds and the year. No utility can possibly provide every format option that someone might find useful. If you really needed that format, and ls were leaner, you would need to write a script (in whatever language). > And -x is a personal preference. Basic utilities shouldn't include so many options that are variants for personal preferences. > None of those seem especially useless. I don't think that they are outrageously useless, but let's set the bar higher. The core utilities should be, in my opinion, much much leaner than they are.