Make cut 1003.2 compliant by adding -b and -n options. This was trivial,
as we don't support multibyte characters yet.
This commit is contained in:
parent
e4127f0401
commit
2ea901d347
@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)cut.1 5.5 (Berkeley) 6/27/91
|
||||
.\" $Id: cut.1,v 1.2 1993/08/01 07:33:18 mycroft Exp $
|
||||
.\" $Id: cut.1,v 1.3 1993/08/16 22:44:50 jtc Exp $
|
||||
.\"
|
||||
.Dd June 27, 1991
|
||||
.Dt CUT 1
|
||||
@ -43,13 +43,17 @@
|
||||
.Nd select portions of each line of a file
|
||||
.Sh SYNOPSIS
|
||||
.Nm cut
|
||||
.Fl b Ar list
|
||||
.Op Fl n
|
||||
.Op Ar
|
||||
.Nm cut
|
||||
.Fl c Ar list
|
||||
.Ar
|
||||
.Op Ar
|
||||
.Nm cut
|
||||
.Fl f Ar list
|
||||
.Op Fl d Ar string
|
||||
.Op Fl d Ar delim
|
||||
.Op Fl s
|
||||
.Ar
|
||||
.Op Ar
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm cut
|
||||
@ -82,22 +86,29 @@ input line.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width Fl
|
||||
.It Fl b Ar list
|
||||
The
|
||||
.Ar list
|
||||
specifies byte positions.
|
||||
.It Fl c Ar list
|
||||
The
|
||||
.Ar list
|
||||
specifies character positions.
|
||||
.It Fl d Ar string
|
||||
.It Fl d Ar delim
|
||||
Use
|
||||
.Ar char
|
||||
.Ar delim
|
||||
as the field delimiter character instead of the tab character.
|
||||
.It Fl f Ar list
|
||||
The
|
||||
.Ar list
|
||||
specifies fields, delimited in the input by a single tab character.
|
||||
Output fields are separated by a single tab character.
|
||||
.It Fl n
|
||||
Do not split multi-byte characters.
|
||||
.It Fl s
|
||||
Suppresses lines with no field delimiter characters.
|
||||
Unless specified, lines with no delimiters are passed through unmodified.
|
||||
Do not
|
||||
.El
|
||||
.Pp
|
||||
.Nm Cut
|
||||
@ -107,5 +118,5 @@ exits 0 on success, 1 if an error occurred.
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm cut
|
||||
utility is expected to conform to
|
||||
utility conforms to
|
||||
.St -p1003.2 .
|
||||
|
@ -42,7 +42,7 @@ char copyright[] =
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)cut.c 5.4 (Berkeley) 10/30/90";*/
|
||||
static char rcsid[] = "$Id: cut.c,v 1.3 1993/08/01 18:16:57 mycroft Exp $";
|
||||
static char rcsid[] = "$Id: cut.c,v 1.4 1993/08/16 22:44:51 jtc Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <limits.h>
|
||||
@ -67,8 +67,11 @@ main(argc, argv)
|
||||
|
||||
dchar = '\t'; /* default delimiter is \t */
|
||||
|
||||
while ((ch = getopt(argc, argv, "c:d:f:s")) != EOF)
|
||||
/* Since we don't support multi-byte characters, the -c and -b
|
||||
options are equivalent, and the -n option is meaningless. */
|
||||
while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != EOF)
|
||||
switch(ch) {
|
||||
case 'b':
|
||||
case 'c':
|
||||
fcn = c_cut;
|
||||
get_list(optarg);
|
||||
@ -86,6 +89,8 @@ main(argc, argv)
|
||||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
case 'n':
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
|
Loading…
Reference in New Issue
Block a user