[Techtalk] what the heck is it with locale and ls -l

Carla Schroder carla at bratgrrl.com
Thu Feb 23 17:24:13 UTC 2012


On Thursday, February 23, 2012 03:31:45 PM John Clarke wrote:
> On Wed, Feb 22, 2012 at 08:02:16PM -0800, Carla Schroder wrote:
> > Both report the same locale-- en_US.UTF-8. So why does Fedora use the
> > irritating date formatting where dates in the current year omit the
> > year?
> 
> Is LC_TIME set to "C" on your Fedora box?  If set, LC_TIME overrides LOCALE
> for date formatting.  What do you get if you run "LC_TIME=en_US.UTF-8 ls
> -l"?
> 
> 
> John

GAH I hit send too soon-- please ignore my previous reply, if it shows up:

I wish it were that simple, John, I had the same thought:

[carla at fedora-verne etc]$ locale| grep -i lc_time
LC_TIME="en_US.UTF-8"

When I add 'export TIME_STYLE=long-iso' to .bash_profile then it displays 
correctly as long-iso.  Without it, it looks like C:

[carla at fedora-verne etc]$ LC_TIME=en_US.UTF-8 ls -l
total 2304
drwxr-xr-x.  3 root root     4096 Nov  2 19:30 abrt
-rw-r--r--.  1 root root       46 Jan 11 11:29 adjtime
-rw-r--r--.  1 root root     1518 Aug 16  2011 aliases

[carla at fedora-verne etc]$ LC_TIME=C ls -l
total 2304
drwxr-xr-x.  3 root root     4096 Nov  2 19:30 abrt
-rw-r--r--.  1 root root       46 Jan 11 11:29 adjtime
-rw-r--r--.  1 root root     1518 Aug 16  2011 aliases

Locale and these ls -l follies always drive me insane.

I learned another way to see what is going on:

[carla at fedora-verne etc]$ locale -k LC_TIME
abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat"
day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday"
abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
mon="January;February;March;April;May;June;July;August;September;October;November;December"
am_pm="AM;PM"
d_t_fmt="%a %d %b %Y %r %Z"
d_fmt="%m/%d/%Y"
t_fmt="%r"
t_fmt_ampm="%I:%M:%S %p"
era=
era_year=""
era_d_fmt=""
alt_digits=
era_d_t_fmt=""
era_t_fmt=""
time-era-num-entries=0
time-era-entries="S"
week-ndays=7
week-1stday=19971130
week-1stweek=7
first_weekday=1
first_workday=2
cal_direction=1
timezone=""
date_fmt="%a %b %e %H:%M:%S %Z %Y"
time-codeset="UTF-8"

carla at studio ~ $ locale -k LC_TIME
abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat"
day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday"
abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
mon="January;February;March;April;May;June;July;August;September;October;November;December"
am_pm="AM;PM"
d_t_fmt="%a %d %b %Y %r %Z"
d_fmt="%m/%d/%Y"
t_fmt="%r"
t_fmt_ampm="%I:%M:%S %p"
era=
era_year=""
era_d_fmt=""
alt_digits=
era_d_t_fmt=""
era_t_fmt=""
time-era-num-entries=0
time-era-entries="S"
week-ndays=7
week-1stday=19971130
week-1stweek=7
first_weekday=1
first_workday=2
cal_direction=1
timezone=""
date_fmt="%a %b %e %H:%M:%S %Z %Y"
time-codeset="UTF-8"

They're both the same. 

There are a couple of simple ways to work around this junk-- set your desired 
TIME_STYLE environmental variable,  or alias ls -l to display the way you 
want. I just wish I knew where the original settings came from in the first 
place.

best,
Carla

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Carla Schroder
ace Linux nerd
author of Linux Cookbook,
Linux Networking Cookbook,
Book of Audacity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the Techtalk mailing list