-.\" $OpenBSD: ls.1,v 1.3 1996/06/23 14:20:19 deraadt Exp $
+.\" $OpenBSD: ls.1,v 1.4 1997/04/01 22:59:36 deraadt Exp $
.\" $NetBSD: ls.1,v 1.14 1995/12/05 02:44:01 jtc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
.Nd list directory contents
.Sh SYNOPSIS
.Nm ls
-.Op Fl ACFLRSTWacdfikloqrstu1
+.Op Fl ACFLRSTWacdfgiklnoqrstu1
.Op Ar file ...
.Sh DESCRIPTION
For each operand that names a
symbolic links in the argument list are not indirected through.
.It Fl f
Output is not sorted.
+.It Fl g
+Does nothing; kept for compatibility with older versions of
+.Xr ls 1 .
.It Fl i
For each file, print the file's file serial number (inode number).
.It Fl k
(The lowercase letter ``ell.'') List in long format. (See below.)
If the output is to a terminal, a total sum for all the file
sizes is output on a line before the long listing.
+.It Fl n
+List in long format as in
+.Fl l ,
+but retain user and group IDs in a numeric format.
.It Fl o
Include the file flags in a long
.Pq Fl l
-output
+output.
.It Fl q
Force printing of non-graphic characters in file names as
the character `?'; this is the default when output is to a terminal.
The
.Fl 1 ,
.Fl C ,
+.Fl l ,
and
-.Fl l
+.Fl n
options all override each other; the last one specified determines
the format used.
.Pp
<blank>s separating the information associated with the
.Fl i ,
.Fl s ,
+.Fl l ,
and
-.Fl l
+.Fl n
options.
.Ss The Long Format
If the
.Fl l
-option is given, the following information
+or
+.Fl n
+options are given, the following information
is displayed for each file:
file mode,
number of links, owner name, group name,
on a line by itself immediately before the information for the files in the
directory.
.Pp
-If the owner or group names are not a known user or group name
-the numeric ID's are displayed.
+If the owner or group names are not a known user or group name,
+or the
+.Fl n
+option is given, the numeric ID's are displayed.
.Pp
If the file is a character special or block special file,
the major and minor device numbers for the file are displayed
linked-to file is preceded by
.Dq \-> .
.Pp
-The file mode printed under the -l option consists of the
-entry type, owner permissions, and group permissions.
-The entry type character describes the type of file, as
+The file mode printed under the
+.Fl l
+or
+.Fl n
+options consists of the entry type, owner permissions, and group
+permissions. The entry type character describes the type of file, as
follows:
.Pp
.Bl -tag -width 4n -offset indent -compact
-/* $OpenBSD: ls.c,v 1.6 1997/01/03 22:36:08 millert Exp $ */
+/* $OpenBSD: ls.c,v 1.7 1997/04/01 22:59:38 deraadt Exp $ */
/* $NetBSD: ls.c,v 1.18 1996/07/09 09:16:29 mycroft Exp $ */
/*
#if 0
static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94";
#else
-static char rcsid[] = "$OpenBSD: ls.c,v 1.6 1997/01/03 22:36:08 millert Exp $";
+static char rcsid[] = "$OpenBSD: ls.c,v 1.7 1997/04/01 22:59:38 deraadt Exp $";
#endif
#endif /* not lint */
int f_newline; /* if precede with newline */
int f_nonprint; /* show unprintables as ? */
int f_nosort; /* don't sort output */
+int f_numericonly; /* don't expand uid to symbolic name */
int f_recursive; /* ls subdirectories also */
int f_reversesort; /* reverse whatever sort is used */
int f_sectime; /* print the real time for all files */
f_listdot = 1;
fts_options = FTS_PHYSICAL;
- while ((ch = getopt(argc, argv, "1ACFLRSTWacdfgikloqrstu")) != -1) {
+ while ((ch = getopt(argc, argv, "1ACFLRSTWacdfgiklnoqrstu")) != -1) {
switch (ch) {
/*
* The -1, -C and -l options all override each other so shell
break;
case 'l':
f_longform = 1;
+ f_numericonly = 0;
+ f_column = f_singlecol = 0;
+ break;
+ case 'n':
+ f_longform = 1;
+ f_numericonly = 1;
f_column = f_singlecol = 0;
break;
/* The -c and -u options override each other. */
int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser;
int entries, needstats;
char *user, *group, buf[20]; /* 32 bits == 10 digits */
+ char nuser[12], ngroup[12];
char *flags = NULL;
/*
btotal += sp->st_blocks;
if (f_longform) {
- user = user_from_uid(sp->st_uid, 0);
+ if (f_numericonly) {
+ snprintf(nuser, 12, "%u", sp->st_uid);
+ snprintf(ngroup, 12, "%u", sp->st_gid);
+ user = nuser;
+ group = ngroup;
+ } else {
+ user = user_from_uid(sp->st_uid, 0);
+ group = group_from_gid(sp->st_gid, 0);
+ }
if ((ulen = strlen(user)) > maxuser)
maxuser = ulen;
- group = group_from_gid(sp->st_gid, 0);
if ((glen = strlen(group)) > maxgroup)
maxgroup = glen;
if (f_flags) {