aboutsummaryrefslogtreecommitdiff
path: root/each.1
blob: 00780bee2eaad4e338d8bfae5c89d34914b534f6 (plain)
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
.Dd $Mdocdate$
.Dt each 1
.Os
.
.Sh NAME
.Nm each
.Nd do with each line
.
.Sh SYNOPSIS
.Nm each
.Ar command
.Op Ar separator command ...
.
.Sh DESCIPTION
.Pp
.Nm
runs each given
.Ar command
for every line read on standard input.
.Ar separator
is one of
.Ql \&; ,
.Ql | ,
.Ql &&
and
.Ql || .
.Pp
Within a command, the contents of the line is assigned to the variable
.Ev x ,
which can be accessed with the normal shell variable interpolation syntax,
except you need to put a plus sign after the dollar sign:
.Bd -literal -offset indent
$+x
$+{x}
$+{x#/}
$+{x%.mp3}
$+{x%%.*}
.Ed
.Pp
This syntax generally doesn't need to be quoted
when entered in the Bourne or Korn shells
(unless you need to put commas inside the curly braces
or have files whose names begin with
.Ql $+ ) .
.Sh AUTHORS
.Pp
.Nm
is written by John Ankarström
.Aq Mt john (at) ankarstrom.se .
.Sh BUGS
.Pp
It is not possible to insert a literal
.Ql $+ .
Quoting it with a backslash prevents the interpolation,
but results in the literal string
.Ql $ .