a bug in /bin/ls

Polytropon freebsd at edvax.de
Sun Aug 16 13:27:42 UTC 2015


On Sun, 16 Aug 2015 15:14:11 +0200, Dr. Andreas Haakh wrote:
> Am 14.08.2015 um 05:26 schrieb Paul Smith:
> > On Thu, Aug 13, 2015 at 5:09 PM, Dr. Andreas Haakh
> > <bugReporter at ib-haakh.de> wrote:
> >> On:
> >> FreeBSD Crabberio.Haakh.de 10.2-PRERELEASE FreeBSD 10.2-PRERELEASE #0
> >> r286580: Mon Aug 10 19:49:05 CEST 2015
> >> toor at Crabberio.Haakh.de:/usr/obj/usr/src/sys/CRABBERIO  amd64
> >>
> >> using the "-U"-flag in /bin/ls  together with "-l"
> >> leads to the following output
> >> [...]
> >> -rwxr--r--  1 krabbe  ibh    798720  1 Jan  1970 IMAG1562.jpg
> >> -rw-r--r--  1 krabbe  ibh    579493  1 Jan  1970 IMAG1714.jpg
> >> [...]
> >>
> >> and the sorting is not affected by the flag (still by name).
> >>
> >>
> >
> > >From the man page:
> >
> > -U     Use time when file was created for sorting or printing.
> >
> > -u     Use time of last access, instead of time of last modification
> > of the file for sorting (-t) or printing (-l).
> >
> > -t     Sort by descending time modified (most recently modified first). . . .
> >
> > Does something like ls -Ult give you what you want? My interpretation
> > is that -u and -U need to be combined with -t or -l.
> >
> > I think the -c option works the same way.
> > Did you get different output on a previous FreeBSD version?
> >
> > Paul
> -Ult returns Jan 1st 1970 as well.

Even with actually different dates (verified with "stat"),
the date sorting options don't seem to have an effect. I have
verified this even on a not-so-recent version of FreeBSD.

The only "solution" would be to do something like this:

	% ls -laF -D "%Y-%m-%d_%H:%M:%S" | sort +5

But that's not what one _should_ have to do, given that there
are date sorting options mentioned in the "ls" manual...




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list