there needs to be a way to get the hour/minute of a file that's more
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 23 Jul 1990 03:56:36 +0000 (19:56 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 23 Jul 1990 03:56:36 +0000 (19:56 -0800)
than six months old.  And ls(1) needs more options anyway.

SCCS-vsn: bin/ls/ls.1 6.14
SCCS-vsn: bin/ls/ls.c 5.43
SCCS-vsn: bin/ls/ls.h 5.11
SCCS-vsn: bin/ls/print.c 5.23
SCCS-vsn: bin/ls/util.c 5.8

usr/src/bin/ls/ls.1
usr/src/bin/ls/ls.c
usr/src/bin/ls/ls.h
usr/src/bin/ls/print.c
usr/src/bin/ls/util.c

index 3f49107..4d3a6a4 100644 (file)
@@ -2,7 +2,7 @@
 .\" All rights reserved.  The Berkeley software License Agreement
 .\" specifies the terms and conditions for redistribution.
 .\"
 .\" All rights reserved.  The Berkeley software License Agreement
 .\" specifies the terms and conditions for redistribution.
 .\"
-.\"            @(#)ls.1        6.13 (Berkeley) %G%
+.\"            @(#)ls.1        6.14 (Berkeley) %G%
 .\"
 .TH LS 1 "%Q"
 .UC
 .\"
 .TH LS 1 "%Q"
 .UC
@@ -11,7 +11,7 @@ ls \- list contents of directory
 .SH SYNOPSIS
 .B ls
 [
 .SH SYNOPSIS
 .B ls
 [
-.B \-1AaCcdFfgikLlqRrstu
+.B \-1AaCcdFfgikLlqRrsTtu
 ] [ file ... ]
 .br
 .SH DESCRIPTION
 ] [ file ... ]
 .br
 .SH DESCRIPTION
@@ -104,6 +104,15 @@ or oldest first as appropriate.
 .B \-s
 Display the sizes of files and directories in 512-byte blocks.
 .TP
 .B \-s
 Display the sizes of files and directories in 512-byte blocks.
 .TP
+.B \-T
+By default, file times less than six months in the past are
+displayed as month, day, hour and minute, and file times more
+than six months in the past are displayed as month, day and
+year.
+The \-T option causes
+.I ls
+to display all file times as month, day, hour, and minute.
+.TP
 .B \-t
 Sort by time modified (latest first) instead of
 by name.
 .B \-t
 Sort by time modified (latest first) instead of
 by name.
index 382c936..863f34d 100644 (file)
@@ -15,7 +15,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)ls.c       5.42 (Berkeley) %G%";
+static char sccsid[] = "@(#)ls.c       5.43 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -50,6 +50,7 @@ int f_nonprint;                       /* show unprintables as ? */
 int f_nosort;                  /* don't sort output */
 int f_recursive;               /* ls subdirectories also */
 int f_reversesort;             /* reverse whatever sort is used */
 int f_nosort;                  /* don't sort output */
 int f_recursive;               /* ls subdirectories also */
 int f_reversesort;             /* reverse whatever sort is used */
+int f_sectime;                 /* print the real time for all files */
 int f_singlecol;               /* use single column output */
 int f_size;                    /* list size in short listing */
 int f_statustime;              /* use time of last mode change */
 int f_singlecol;               /* use single column output */
 int f_size;                    /* list size in short listing */
 int f_statustime;              /* use time of last mode change */
@@ -87,7 +88,7 @@ main(argc, argv)
        if (!getuid())
                f_listdot = 1;
 
        if (!getuid())
                f_listdot = 1;
 
-       while ((ch = getopt(argc, argv, "1ACFLRacdfgiklqrstu")) != EOF) {
+       while ((ch = getopt(argc, argv, "1ACFLRTacdfgiklqrstu")) != EOF) {
                switch (ch) {
                /*
                 * -1, -C and -l all override each other
                switch (ch) {
                /*
                 * -1, -C and -l all override each other
@@ -155,6 +156,9 @@ main(argc, argv)
                case 's':
                        f_size = 1;
                        break;
                case 's':
                        f_size = 1;
                        break;
+               case 'T':
+                       f_sectime = 1;
+                       break;
                case 't':
                        f_timesort = 1;
                        break;
                case 't':
                        f_timesort = 1;
                        break;
index b967990..1534bd9 100644 (file)
@@ -7,7 +7,7 @@
  *
 %sccs.include.redist.c%
  *
  *
 %sccs.include.redist.c%
  *
- *     @(#)ls.h        5.10 (Berkeley) %G%
+ *     @(#)ls.h        5.11 (Berkeley) %G%
  */
 
 typedef struct _lsstruct {
  */
 
 typedef struct _lsstruct {
@@ -32,6 +32,7 @@ extern int f_group;           /* show group ownership of a file */
 extern int f_inode;            /* print inode */
 extern int f_kblocks;          /* print size in kilobytes */
 extern int f_longform;         /* long listing format */
 extern int f_inode;            /* print inode */
 extern int f_kblocks;          /* print size in kilobytes */
 extern int f_longform;         /* long listing format */
+extern int f_sectime;          /* print the real time for all files */
 extern int f_singlecol;                /* use single column output */
 extern int f_size;             /* list size in short listing */
 extern int f_statustime;       /* use time of last mode change */
 extern int f_singlecol;                /* use single column output */
 extern int f_size;             /* list size in short listing */
 extern int f_statustime;       /* use time of last mode change */
index d0423a4..27bf38a 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)print.c    5.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c    5.23 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -158,7 +158,7 @@ printtime(ftime)
                (void)putchar(longstring[i]);
 
 #define        SIXMONTHS       ((DAYSPERNYEAR / 2) * SECSPERDAY)
                (void)putchar(longstring[i]);
 
 #define        SIXMONTHS       ((DAYSPERNYEAR / 2) * SECSPERDAY)
-       if (ftime + SIXMONTHS > time((time_t *)NULL))
+       if (f_sectime || ftime + SIXMONTHS > time((time_t *)NULL))
                for (i = 11; i < 16; ++i)
                        (void)putchar(longstring[i]);
        else {
                for (i = 11; i < 16; ++i)
                        (void)putchar(longstring[i]);
        else {
index 59657c1..77f9523 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)util.c     5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c     5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -47,6 +47,6 @@ nomem()
 
 usage()
 {
 
 usage()
 {
-       (void)fprintf(stderr, "usage: ls [-1ACFLRacdfgiklqrstu] [file ...]\n");
+       (void)fprintf(stderr, "usage: ls [-1ACFLRTacdfgiklqrstu] [file ...]\n");
        exit(1);
 }
        exit(1);
 }