Bug 227111 - ls: -c option does nothing
Summary: ls: -c option does nothing
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-30 12:46 UTC by emz
Modified: 2018-03-30 13:57 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emz 2018-03-30 12:46:41 UTC
ls -c option does nothing. unlike linux, where it actually makes ls to sort according to mtime.

Proof:
Below are three ls outputs, including -l output which shows that even with -c option the output is sorted alphabetically, and not according to mtime.

===Cut===
root@san1:bin/ls]# ls -1 /home/emz 
.cache
.config
.cshrc
.gitconfig
.histfile
.history
.lesshst
.local
.login
.login_conf
.mail_aliases
.mailrc
.profile
.rhosts
.shrc
.ssh
.subversion
.wget-hsts
.zshrc
4600-protocols.txt
backups
blockdev.txt
clone-disks.sh
corrupted-userdata.txt
corrupted-userdata.txt.0
corrupted-userdata.txt.1
corrupted-userdata.txt.2
corrupted-userdata.txt.3
corrupted-userdata.txt.4
corrupted-userdata.txt.5
corrupted-userdata.txt.6
corrupted-userdata.txt.7
corrupted-userdata.txt.8
corrupted-userdata.txt.9
create-userdata.sh
ctl
ctl.conf
ctl.conf.games
ctl.conf.userdata
ctl.conf.userdata.2nd
ctl.conf.userdata.gap
ctladm.txt
ctld
ctld-locking
cycle-reload.sh
delete-userdata.sh
drop-snapshots.sh
dumps
ether-switching-table.txt
ether-switching-table.txt.sw0
get-smart-errors-count.sh
intel
linx.txt
lsi
lynx-plan-nat.txt
mac-2-ip.sh
mac-2-ip.txt
mellanox
nginx
recreate-corrupted-userdata.sh
resolve-bulk-data.sh
sandisk
send-userdata.sh
smart-errors.0.txt
snapshots-2-drop.txt
snmpwalk-sw0-lynx.txt
sw0-linx-ports.txt
sw1-linx-ports.txt
test-remove.sh
test.file
update-userdata.sh
userdata.txt
watch-mem.sh
zfsapi
 [root@san1:bin/ls]# ls -1c /home/emz
.cache
.config
.cshrc
.gitconfig
.histfile
.history
.lesshst
.local
.login
.login_conf
.mail_aliases
.mailrc
.profile
.rhosts
.shrc
.ssh
.subversion
.wget-hsts
.zshrc
4600-protocols.txt
backups
blockdev.txt
clone-disks.sh
corrupted-userdata.txt
corrupted-userdata.txt.0
corrupted-userdata.txt.1
corrupted-userdata.txt.2
corrupted-userdata.txt.3
corrupted-userdata.txt.4
corrupted-userdata.txt.5
corrupted-userdata.txt.6
corrupted-userdata.txt.7
corrupted-userdata.txt.8
corrupted-userdata.txt.9
create-userdata.sh
ctl
ctl.conf
ctl.conf.games
ctl.conf.userdata
ctl.conf.userdata.2nd
ctl.conf.userdata.gap
ctladm.txt
ctld
ctld-locking
cycle-reload.sh
delete-userdata.sh
drop-snapshots.sh
dumps
ether-switching-table.txt
ether-switching-table.txt.sw0
get-smart-errors-count.sh
intel
linx.txt
lsi
lynx-plan-nat.txt
mac-2-ip.sh
mac-2-ip.txt
mellanox
nginx
recreate-corrupted-userdata.sh
resolve-bulk-data.sh
sandisk
send-userdata.sh
smart-errors.0.txt
snapshots-2-drop.txt
snmpwalk-sw0-lynx.txt
sw0-linx-ports.txt
sw1-linx-ports.txt
test-remove.sh
test.file
update-userdata.sh
userdata.txt
watch-mem.sh
zfsapi
[root@san1:bin/ls]# ls -l /home/emz 
total 104198
drwx------  3 emz   wheel          3 Aug  2  2017 .cache
drwx------  3 emz   wheel          3 Aug  2  2017 .config
-rw-r--r--  1 emz   wheel       1055 Aug  2  2017 .cshrc
-rw-r--r--  1 emz   wheel        154 Nov  3 16:39 .gitconfig
-rw-------  1 emz   wheel      19843 Mar 29 18:52 .histfile
-rw-------  1 emz   wheel         38 Aug  2  2017 .history
-rw-------  1 emz   wheel        128 Feb 14 21:29 .lesshst
drwx------  3 emz   wheel          3 Aug  2  2017 .local
-rw-r--r--  1 emz   wheel        254 Aug  2  2017 .login
-rw-r--r--  1 emz   wheel        163 Aug  2  2017 .login_conf
-rw-------  1 emz   wheel        379 Aug  2  2017 .mail_aliases
-rw-r--r--  1 emz   wheel        336 Aug  2  2017 .mailrc
-rw-r--r--  1 emz   wheel        802 Aug  2  2017 .profile
-rw-------  1 emz   wheel        281 Aug  2  2017 .rhosts
-rw-r--r--  1 emz   wheel        849 Aug  2  2017 .shrc
drwx------  2 emz   wheel          6 Feb 28 10:47 .ssh
drwxr-xr-x  3 emz   wheel          6 Aug  2  2017 .subversion
-rw-r--r--  1 emz   wheel        181 Nov 15 14:15 .wget-hsts
-rw-r--r--  1 emz   wheel       1471 Aug  2  2017 .zshrc
-rw-r--r--  1 emz   wheel       2427 Oct  3 19:04 4600-protocols.txt
drwxr-xr-x  2 emz   wheel          6 Aug  2  2017 backups
-rw-r--r--  1 emz   wheel      43548 Aug 23  2017 blockdev.txt
-rwxr-xr-x  1 emz   wheel        839 Nov  2 13:20 clone-disks.sh
-rw-r--r--  1 emz   wheel         90 Aug 16  2017 corrupted-userdata.txt
-rw-r--r--  1 emz   wheel        513 Aug  2  2017 corrupted-userdata.txt.0
-rw-r--r--  1 emz   wheel        513 Aug  6  2017 corrupted-userdata.txt.1
-rw-r--r--  1 emz   wheel        126 Aug  6  2017 corrupted-userdata.txt.2
-rw-r--r--  1 emz   wheel         48 Aug  6  2017 corrupted-userdata.txt.3
-rw-r--r--  1 emz   wheel        290 Aug  6  2017 corrupted-userdata.txt.4
-rw-r--r--  1 emz   wheel         72 Aug  6  2017 corrupted-userdata.txt.5
-rw-r--r--  1 emz   wheel         24 Aug  6  2017 corrupted-userdata.txt.6
-rw-r--r--  1 emz   wheel         30 Aug  7  2017 corrupted-userdata.txt.7
-rw-r--r--  1 emz   wheel         30 Aug  7  2017 corrupted-userdata.txt.8
-rw-r--r--  1 emz   wheel        100 Aug  8  2017 corrupted-userdata.txt.9
-rwxr-xr-x  1 emz   wheel        800 Dec 22 14:37 create-userdata.sh
drwxr-xr-x  2 emz   wheel          4 Feb 14 14:14 ctl
-rw-------  1 emz   wheel     126330 Sep 22  2017 ctl.conf
-rw-r--r--  1 emz   wheel     104258 Nov  2 13:20 ctl.conf.games
-rw-r--r--  1 emz   wheel      92973 Dec 22 12:42 ctl.conf.userdata
-rw-r--r--  1 emz   wheel      27840 Oct 19 18:58 ctl.conf.userdata.2nd
-rw-r--r--  1 emz   wheel      27840 Dec 22 14:37 ctl.conf.userdata.gap
-rw-r--r--  1 emz   wheel     218034 Oct  4 14:52 ctladm.txt
drwxr-xr-x  2 emz   wheel          3 Feb 14 14:15 ctld
drwxr-xr-x  3 emz   wheel          8 Feb 13 19:34 ctld-locking
-rwxr-xr-x  1 emz   wheel        250 Aug 10  2017 cycle-reload.sh
-rwxr-xr-x  1 emz   wheel        235 Aug  2  2017 delete-userdata.sh
-rwxr-xr-x  1 emz   wheel        134 Nov  2 17:09 drop-snapshots.sh
drwxr-xr-x  2 emz   wheel          6 Nov  2 11:56 dumps
-rw-r--r--  1 emz   wheel      26376 Oct 27 18:10 ether-switching-table.txt
-rw-r--r--  1 emz   wheel      23352 Aug 24  2017 ether-switching-table.txt.sw0
-rwxr-xr-x  1 emz   wheel        264 Aug  2  2017 get-smart-errors-count.sh
drwxr-xr-x  4 emz   wheel          7 Nov 22 19:34 intel
-rw-r--r--  1 emz   wheel      17341 Oct 27 18:24 linx.txt
drwxr-xr-x  3 emz   wheel         10 Feb 26 17:56 lsi
-rw-r--r--  1 emz   wheel        863 Sep 12  2017 lynx-plan-nat.txt
-rwxr-xr-x  1 emz   wheel        403 Aug 24  2017 mac-2-ip.sh
-rw-r--r--  1 emz   wheel      17118 Oct 27 18:14 mac-2-ip.txt
drwxr-xr-x  3 emz   wheel          7 Feb 27 15:24 mellanox
drwxr-xr-x  2 emz   wheel         10 Oct 27 17:48 nginx
-rwxr-xr-x  1 emz   wheel        602 Aug 16  2017 recreate-corrupted-userdata.sh
-rwxr-xr-x  1 emz   wheel       1153 Oct 27 18:20 resolve-bulk-data.sh
drwxr-xr-x  2 emz   wheel          5 Aug  2  2017 sandisk
-rwxr-xr-x  1 emz   wheel        219 Oct 13 00:17 send-userdata.sh
-rw-r--r--  1 emz   wheel        276 Aug  2  2017 smart-errors.0.txt
-rw-r--r--  1 emz   wheel      16250 Mar  5 12:39 snapshots-2-drop.txt
-rw-r--r--  1 emz   wheel     574748 Sep 12  2017 snmpwalk-sw0-lynx.txt
-rw-r--r--  1 emz   wheel      21830 Aug 24  2017 sw0-linx-ports.txt
-rw-r--r--  1 emz   wheel      62518 Aug 24  2017 sw1-linx-ports.txt
-rwxr-xr-x  1 emz   wheel        123 Jan 16 13:27 test-remove.sh
-rw-r--r--  1 emz   wheel  104857600 Nov 14 11:44 test.file
-rwxr-xr-x  1 emz   wheel        167 Aug  2  2017 update-userdata.sh
-rw-r--r--  1 root  wheel      13130 Mar  5 12:33 userdata.txt
-rwxr-xr-x  1 emz   wheel         68 Aug  2  2017 watch-mem.sh
drwxr-xr-x  3 emz   wheel          6 Mar  1 12:24 zfsapi
[root@san1:bin/ls]#
===Cut===

One may think that this is may be because of the ZFS, wgich is currently my fs.
Here's the output from old 10.2-STABLE with ufs, demonstrating that the problem exists long ago:

===Cut===
[emz@kuznetsova16-1:~]> uname -a
FreeBSD kuznetsova16-1.norman-trade.ru 10.2-STABLE FreeBSD 10.2-STABLE #3 r286954M: Tue Nov  3 14:30:03 MSK 2015     emz@moscow-alpha:/usr/obj/nanobsd.alix/i386.i386/usr/src/sys/ALIX  i386
[emz@kuznetsova16-1:~]> mount
/dev/ad0s1a on / (ufs, local, read-only)
devfs on /dev (devfs, local, multilabel)
/dev/md0 on /etc (ufs, local)
/dev/md1 on /var (ufs, local)
[emz@kuznetsova16-1:~]> ls -1 /var/log
auth.log
auth.log.0.bz2
auth.log.1.bz2
auth.log.2.bz2
auth.log.3.bz2
auth.log.4.bz2
auth.log.5.bz2
auth.log.6.bz2
cron
cron.0.bz2
cron.1.bz2
cron.2.bz2
debug.log
lpd-errs
maillog
maillog.0.bz2
maillog.1.bz2
maillog.2.bz2
maillog.3.bz2
maillog.4.bz2
maillog.5.bz2
maillog.6.bz2
messages
messages.0.bz2
messages.1.bz2
messages.2.bz2
messages.3.bz2
messages.4.bz2
ppp.log
security
sendmail.st
sendmail.st.0
sendmail.st.1
sendmail.st.2
sendmail.st.3
sendmail.st.4
sendmail.st.5
sendmail.st.6
userlog
utx.lastlogin
utx.log
xferlog
[emz@kuznetsova16-1:~]> ls -1c /var/log
auth.log
auth.log.0.bz2
auth.log.1.bz2
auth.log.2.bz2
auth.log.3.bz2
auth.log.4.bz2
auth.log.5.bz2
auth.log.6.bz2
cron
cron.0.bz2
cron.1.bz2
cron.2.bz2
debug.log
lpd-errs
maillog
maillog.0.bz2
maillog.1.bz2
maillog.2.bz2
maillog.3.bz2
maillog.4.bz2
maillog.5.bz2
maillog.6.bz2
messages
messages.0.bz2
messages.1.bz2
messages.2.bz2
messages.3.bz2
messages.4.bz2
ppp.log
security
sendmail.st
sendmail.st.0
sendmail.st.1
sendmail.st.2
sendmail.st.3
sendmail.st.4
sendmail.st.5
sendmail.st.6
userlog
utx.lastlogin
utx.log
xferlog
[emz@kuznetsova16-1:~]> ls -l /var/log  
total 348
-rw-------  1 root  wheel    21219 Mar 30 12:44 auth.log
-rw-------  1 root  wheel     7809 Mar 30 09:00 auth.log.0.bz2
-rw-------  1 root  wheel     7705 Mar 30 01:00 auth.log.1.bz2
-rw-------  1 root  wheel     9121 Mar 29 20:00 auth.log.2.bz2
-rw-------  1 root  wheel     8652 Mar 29 05:00 auth.log.3.bz2
-rw-------  1 root  wheel    36346 Mar 28 17:00 auth.log.4.bz2
-rw-------  1 root  wheel    16898 Mar 28 16:00 auth.log.5.bz2
-rw-------  1 root  wheel     8548 Mar 28 07:00 auth.log.6.bz2
-rw-------  1 root  wheel    30955 Mar 30 12:45 cron
-rw-------  1 root  wheel     4675 Mar 29 19:00 cron.0.bz2
-rw-------  1 root  wheel     4852 Mar 27 08:00 cron.1.bz2
-rw-------  1 root  wheel     4851 Mar 24 21:00 cron.2.bz2
-rw-------  1 root  wheel     4562 Mar 30 12:44 debug.log
-rw-r--r--  1 root  wheel       69 Feb 13 11:18 lpd-errs
-rw-r-----  1 root  wheel       69 Mar 30 00:00 maillog
-rw-r-----  1 root  wheel      129 Mar 30 00:00 maillog.0.bz2
-rw-r-----  1 root  wheel      129 Mar 29 00:00 maillog.1.bz2
-rw-r-----  1 root  wheel      127 Mar 28 00:00 maillog.2.bz2
-rw-r-----  1 root  wheel      127 Mar 27 00:00 maillog.3.bz2
-rw-r-----  1 root  wheel      127 Mar 26 00:00 maillog.4.bz2
-rw-r-----  1 root  wheel      127 Mar 25 00:00 maillog.5.bz2
-rw-r-----  1 root  wheel      127 Mar 24 00:00 maillog.6.bz2
-rw-r--r--  1 root  wheel    47116 Mar 30 12:38 messages
-rw-r--r--  1 root  wheel     7441 Mar 28 17:00 messages.0.bz2
-rw-r--r--  1 root  wheel     5894 Mar 28 16:00 messages.1.bz2
-rw-r--r--  1 root  wheel     5191 Mar 26 07:00 messages.2.bz2
-rw-r--r--  1 root  wheel     6494 Mar 24 21:00 messages.3.bz2
-rw-r--r--  1 root  wheel     8197 Mar 24 20:00 messages.4.bz2
-rw-r-----  1 root  network     69 Feb 13 11:18 ppp.log
-rw-------  1 root  wheel       69 Feb 13 11:18 security
-rw-r-----  1 root  wheel        0 Mar 27 12:00 sendmail.st
-rw-r-----  1 root  wheel        0 Mar 27 12:00 sendmail.st.0
-rw-r-----  1 root  wheel        0 Mar 20 12:00 sendmail.st.1
-rw-r-----  1 root  wheel        0 Mar 13 12:00 sendmail.st.2
-rw-r-----  1 root  wheel        0 Mar  6 12:00 sendmail.st.3
-rw-r-----  1 root  wheel        0 Feb 27 12:00 sendmail.st.4
-rw-r-----  1 root  wheel        0 Feb 20 12:00 sendmail.st.5
-rw-r-----  1 root  wheel        0 Feb 13 12:00 sendmail.st.6
-rw-------  1 root  wheel      149 Nov  3  2015 userlog
-rw-r--r--  1 root  wheel      197 Mar 30 12:44 utx.lastlogin
-rw-r--r--  1 root  wheel      198 Mar 30 12:44 utx.log
-rw-------  1 root  wheel       69 Feb 13 11:18 xferlog
[emz@kuznetsova16-1:~]>
===Cut===
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2018-03-30 13:57:38 UTC
It doesn't do nothing -- it changes the printed time field and sorted-by time field to be the "changed" date.  Even with plain 'ls -l' vs 'ls -cl' I can observe this on my directories.  E.g.,


$ ls -l nacl-20110221.tar.bz2
-rw-r--r--  1 conrad  conrad  163415 Feb 20  2011 nacl-20110221.tar.bz2
$ ls -lc nacl-20110221.tar.bz2       ^^^^^^^^^^^^
-rw-r--r--  1 conrad  conrad  163415 Mar 10 11:02 nacl-20110221.tar.bz2
                                     ^^^^^^^^^^^^
$ stat -x nacl-20110221.tar.bz2
  File: "nacl-20110221.tar.bz2"
  Size: 163415       FileType: Regular File
  Mode: (0644/-rw-r--r--)         Uid: ( 1001/  conrad)  Gid: ( 1001/  conrad)
Device: 0,70   Inode: 35232639    Links: 1
Access: Sat Mar 10 11:02:59 2018
Modify: Sun Feb 20 17:49:40 2011
Change: Sat Mar 10 11:02:59 2018


For sorting, it's a modifier flag for 't', which actually induces time-based sorting.  Try 'ls -lt' vs 'ls -clt'.

The documentation could be more clear.