-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpick.1
135 lines (135 loc) · 2.7 KB
/
pick.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
.Dd September 23, 2022
.Dt PICK 1
.Os
.Sh NAME
.Nm pick
.Nd interactivelly select arguments
.Sh SYNOPSIS
.Nm
.Op Fl bnq
.Op Fl d Ar delimiter
.Op Ar arg ...
.IR arg ...
.Sh DESCRIPTION
.Nm
prints each option in turn and asks the user for a response;
if the response is
.Ic y ,
the option is printed to standard output. If
>nm
receives
.Ic "-"
(an hyphen)
as only argument, each option is a line from the standard input;
otherwise, each option is a different argument.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl b
Escape whitespace by printing a backslash before it.
This option overrides the
.Ev QUOTING_STYLE
environment variable.
This option is incompatible with
.Fl q .
.It Fl d Ar delimiter
Use
.Ar delimiter
as argument separator, rather than newline.
This option is incompatible with
.Fl n .
.It Fl q
Quote each option with single quotes just as shell quoting.
This option overrides the
.Ev QUOTING_STYLE
environment variable.
This option is incompatible with
.Fl b .
.It Fl n
Do not separate options by newline, separate by a single space, instead.
This option is incompatible with
.Fl d .
.El
.Pp
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm
.Bl -tag -width Ds
.It Ev QUOTING_STYLE
If set to
.Dq "escape" ,
.Nm
behaves as if the option
.Fl b
is set, thus whitespaces are escaped with backslashes.
If set to
.Dq "shell" ,
.Nm
behaves as if the option
.Fl q
is set, thus options are quoted between single quotes as in shell quoting.
If set to
.Dq "literal" ,
options are output as is.
.Sh EXAMPLES
.Nm
can be used to interactivelly remove files with
.Xr rm 1 .
This example is equivalent to rm's
.Fl i
(interactive) option,
but can be used with other commands that, unlike
.Xr rm 1 ,
does not provide a
.Fl i
option.
.Bd -literal -offset indent
$ rm `pick *`
.Ed
.Pp
The following example is equivalent to the previous one, but uses the
standard input fed by the
.Xr ls 1
utility.
.Bd -literal -offset indent
$ rm `ls | pick -`
.Ed
.Pp
The previous examples rely on the condition that each filename does not contain space in it.
If a file contains space, it would be considered as a field separator.
One option to avoid this is using
.Xr xargs 1
with the option
.Fl d Cm "\en"
to consider only the newline output by
.Nm
as the field separator.
.Bd -literal -offset indent
$ pick * | xargs -d '\\n' rm
.Ed
.Pp
Another option is to use a quoting option, such as
.Fl q
on
.Nm ,
and pipe it into
.Xr xargs 1 :
.Bd -literal -offset indent
$ pick -q * | xargs rm
.Ed
.Sh SEE ALSO
.Xr xargs 1
.Rs
.%A Brian W. Kernighan
.%A Rob Pike
.%B "The UNIX Programming Environment"
.%I "Prentice Hall"
.%D 1984
.Re
.Sh HISTORY
An
.Nm
utility appeared as an exemple in the book
.Rs
.%B "The UNIX Programming Environment"
.Re