2010/10/8 Pádraig Brady <[email protected]>: > On 08/10/10 17:15, Philip Ganchev wrote: >> On a related note, couldn't all GNU programs (such as "du" and "ls") >> be made to print (and read?) numbers and dates formatted according to >> the locale setting, including thousands-separators, etc? That would >> avoid having a special option for every program. > > BLOCK_SIZE can be used to control a few output formats: > > export BLOCK_SIZE=\'1; export LC_ALL=de_DE.utf8 > > $ \ls -ld . > drwxrwxr-x. 4 padraig padraig 4.096 15. Sep 23:04 . > $ du -s . > 15.368.192 > $ df . > Dateisystem 1B-Blöcke Benutzt Verfügbar Ben% Eingehängt auf > /dev/sda5 5.155.188.736 4.930.887.680 171.970.560 97% /
OK, great -- thanks! Maybe BLOCK_SIZE should be mentioned in the manual page or the info page of the programs that respect it? It does not seem to be widely known -- I did not know about it. (Maybe it is already in the latest versions.) (It's too bad that non-GNU programs like "ps" don't use those variables. And I think there should be a more general number format variable to allow other programs outputting numbers, such as "nl", should be able to output numbers with thousands separators.) > I do notice that stat doesn't pass on a single > quote to the underlying printf to get locale specific output. > Maybe we want to support that? > > $ stat -c%\'s . > ?s > > $ stat -c%08s . > 00004096 It seems to my naive eyes that it ought to be supported. It should also respect the BLOCK_SIZE (or BLOCKSIZE?) variable. > Also sort can read locale specific separators: > > $ printf '1 234\n1 123\n' | LC_ALL=fr_FR.utf8 sort --debug -sn > sort: using `fr_FR.utf8' sorting rules > 1 123 > _____ > 1 234 > _____ Great! > As for dates, it's hard enough to read in a single > locale, never mind supporting multiple locales. Can't "sort" rely on the "date" program (library) to recognize and convert dates to an unambiguous time stamp? Maybe it would be slow check every string if it's a date, but just do it when an option is specified? Philip
