summaryrefslogtreecommitdiff
path: root/man/man1/strjoin.1
blob: 2e01e33148d7757429e8a4571ebad37f6f06bc34 (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
.TH strjoin 1 2023-07-03 utils

.SH NAME
strjoin \- join words with a word

.SH SYNOPSIS
.B strjoin
.IR separator \ [ word\ ... ]

.SH DESCRIPTION
.B strjoin
is the command line equivalent of
.BR python (1)'s
.B str.join(...)
and
.BR java (1)'s
.BR Stream<String>.collect(Collectors.joining(...)) .
For most purposes,
it is functionally almost identical to
.RS
.B strjoin(){ declare IFS=$1;shift;echo \(dq$*\(dq;}
.RE
in
.BR bash (1),
except the separator can be more than one character,
and also, lines to be joined can be read from
.BR stdin (3),
similar to
.BR paste (1)\  \-s ,
except that with
.BR strjoin ,
the separator can be more than one character.
.P
The first parameter is the separator
that goes between the words.
All other parameters are the words.
(They don't have to be single words, but they are treated as such.)

.SH EXAMPLES
.TP
.B strjoin\  ++\ foo\ bar\ baz
Prints \(lqfoo++bar++baz\(rq.
.TP
.BR printf\ \(aq%s\en\(aq\  foo\ bar\ baz\  |\ strjoin\  --
Prints \(lqfoo--bar--baz\(rq, reading the words from stdin.
Useful for making lists of file names, for example.

.SH SEE ALSO
.BR paste (1),\  tr (1)