mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Document string split0
This commit is contained in:
parent
d34a300818
commit
b1176323e7
1 changed files with 15 additions and 0 deletions
|
@ -14,6 +14,8 @@ string replace [(-a | --all)] [(-f | --filter)] [(-i | --ignore-case)] [(-r | --
|
||||||
[(-q | --quiet)] PATTERN REPLACEMENT [STRING...]
|
[(-q | --quiet)] PATTERN REPLACEMENT [STRING...]
|
||||||
string split [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] SEP
|
string split [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] SEP
|
||||||
[STRING...]
|
[STRING...]
|
||||||
|
string split0 [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)]
|
||||||
|
[STRING...]
|
||||||
string sub [(-s | --start) START] [(-l | --length) LENGTH] [(-q | --quiet)]
|
string sub [(-s | --start) START] [(-l | --length) LENGTH] [(-q | --quiet)]
|
||||||
[STRING...]
|
[STRING...]
|
||||||
string trim [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)]
|
string trim [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)]
|
||||||
|
@ -93,6 +95,12 @@ Exit status: 0 if at least one replacement was performed, or 1 otherwise.
|
||||||
|
|
||||||
See also `read --delimiter`.
|
See also `read --delimiter`.
|
||||||
|
|
||||||
|
\subsection string-split0 "split0" subcommand
|
||||||
|
|
||||||
|
`string split0` splits each STRING on the zero byte (NUL). Options are the same as `string split` except that no separator is given.
|
||||||
|
|
||||||
|
`split0` has the important property that its output is not further split when used in a command substitution, allowing for the command substitution to produce elements containing newlines. This is most useful when used with Unix tools that produce zero bytes, such as `find -print0` or `sort -z`. See split0 examples below.
|
||||||
|
|
||||||
\subsection string-sub "sub" subcommand
|
\subsection string-sub "sub" subcommand
|
||||||
|
|
||||||
`string sub` prints a substring of each string argument. The start of the substring can be specified with `-s` or `--start` followed by a 1-based index value. Positive index values are relative to the start of the string and negative index values are relative to the end of the string. The default start value is 1. The length of the substring can be specified with `-l` or `--length`. If the length is not specified, the substring continues to the end of each STRING. Exit status: 0 if at least one substring operation was performed, 1 otherwise.
|
`string sub` prints a substring of each string argument. The start of the substring can be specified with `-s` or `--start` followed by a 1-based index value. Positive index values are relative to the start of the string and negative index values are relative to the end of the string. The default start value is 1. The length of the substring can be specified with `-l` or `--length`. If the length is not specified, the substring continues to the end of each STRING. Exit status: 0 if at least one substring operation was performed, 1 otherwise.
|
||||||
|
@ -240,6 +248,13 @@ foo2
|
||||||
<outp>0xBadC0de</outp>
|
<outp>0xBadC0de</outp>
|
||||||
\endfish
|
\endfish
|
||||||
|
|
||||||
|
\subsection string-example-split0 Split0 Examples
|
||||||
|
|
||||||
|
\fish{cli-dark}
|
||||||
|
# Count files in a directory, without being confused by newlines.
|
||||||
|
>_ count (find . -print0 | string split0)
|
||||||
|
\endfish
|
||||||
|
|
||||||
\subsection string-example-replace-literal Replace Literal Examples
|
\subsection string-example-replace-literal Replace Literal Examples
|
||||||
|
|
||||||
\fish{cli-dark}
|
\fish{cli-dark}
|
||||||
|
|
Loading…
Reference in a new issue