1SYSTEMD-ESCAPE(1)               systemd-escape               SYSTEMD-ESCAPE(1)
2
3
4

NAME

6       systemd-escape - Escape strings for usage in systemd unit names
7

SYNOPSIS

9       systemd-escape [OPTIONS...] [STRING...]
10

DESCRIPTION

12       systemd-escape may be used to escape strings for inclusion in systemd
13       unit names. The command may be used to escape and to undo escaping of
14       strings.
15
16       The command takes any number of strings on the command line, and will
17       process them individually, one after another. It will output them
18       separated by spaces to stdout.
19
20       By default, this command will escape the strings passed, unless
21       --unescape is passed which results in the inverse operation being
22       applied. If --mangle is given, a special mode of escaping is applied
23       instead, which assumes the string is already escaped but will escape
24       everything that appears obviously non-escaped.
25
26       For details on the escaping and unescaping algorithms see the relevant
27       section in systemd.unit(5).
28

OPTIONS

30       The following options are understood:
31
32       --suffix=
33           Appends the specified unit type suffix to the escaped string. Takes
34           one of the unit types supported by systemd, such as "service" or
35           "mount". May not be used in conjunction with --template=,
36           --unescape or --mangle.
37
38       --template=
39           Inserts the escaped strings in a unit name template. Takes a unit
40           name template such as foobar@.service. With --unescape, expects
41           instantiated unit names for this template and extracts and
42           unescapes just the instance part. May not be used in conjunction
43           with --suffix=, --instance or --mangle.
44
45       --path, -p
46           When escaping or unescaping a string, assume it refers to a file
47           system path. This eliminates leading, trailing or duplicate "/"
48           characters and rejects "."  and ".."  path components. This is
49           particularly useful for generating strings suitable for unescaping
50           with the "%f" specifier in unit files, see systemd.unit(5).
51
52       --unescape, -u
53           Instead of escaping the specified strings, undo the escaping,
54           reversing the operation. May not be used in conjunction with
55           --suffix= or --mangle.
56
57       --mangle, -m
58           Like --escape, but only escape characters that are obviously not
59           escaped yet, and possibly automatically append an appropriate unit
60           type suffix to the string. May not be used in conjunction with
61           --suffix=, --template= or --unescape.
62
63       --instance
64           With --unescape, unescape and print only the instance part of an
65           instantiated unit name template. Results in an error for an
66           uninstantiated template like ssh@.service or a non-template name
67           like ssh.service. Must be used in conjunction with --unescape and
68           may not be used in conjunction with --template.
69
70       -h, --help
71           Print a short help text and exit.
72
73       --version
74           Print a short version string and exit.
75

EXAMPLES

77       To escape a single string:
78
79           $ systemd-escape 'Hallöchen, Meister'
80           Hall\xc3\xb6chen\x2c\x20Meister
81
82       To undo escaping on a single string:
83
84           $ systemd-escape -u 'Hall\xc3\xb6chen\x2c\x20Meister'
85           Hallöchen, Meister
86
87       To generate the mount unit for a path:
88
89           $ systemd-escape -p --suffix=mount "/tmp//waldi/foobar/"
90           tmp-waldi-foobar.mount
91
92       To generate instance names of three strings:
93
94           $ systemd-escape --template=systemd-nspawn@.service 'My Container 1' 'containerb' 'container/III'
95           systemd-nspawn@My\x20Container\x201.service systemd-nspawn@containerb.service systemd-nspawn@container-III.service
96
97       To extract the instance part of an instantiated unit:
98
99           $ systemd-escape -u --instance 'systemd-nspawn@My\x20Container\x201.service'
100           My Container 1
101
102       To extract the instance part of an instance of a particular template:
103
104           $ systemd-escape -u --template=systemd-nspawn@.service 'systemd-nspawn@My\x20Container\x201.service'
105           My Container 1
106

EXIT STATUS

108       On success, 0 is returned, a non-zero failure code otherwise.
109

SEE ALSO

111       systemd(1), systemd.unit(5), systemctl(1)
112
113
114
115systemd 254                                                  SYSTEMD-ESCAPE(1)
Impressum