Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
STRING-SPLIT(1)			  fish-shell		       STRING-SPLIT(1)

NAME
       string-split - split strings by delimiter

SYNOPSIS
	  string split [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)]	SEP [STRING...]
	  string split0	[(-m | --max) MAX] [(-n	| --no-empty)] [(-q | --quiet)]	[(-r | --right)] [STRING...]

DESCRIPTION
       string  split  splits each STRING on the	separator SEP, which can be an
       empty string. If	-m or --max is specified, at most MAX splits are  done
       on  each	 STRING.  If  -r  or  --right is given,	splitting is performed
       right-to-left. This is useful in	combination with -m or --max. With  -n
       or  --no-empty,	empty  results	are  excluded from consideration (e.g.
       hello\n\nworld would expand to two strings and not three). Exit status:
       0 if at least one split was performed, or 1 otherwise.

       See also	read --delimiter.

       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 substitu-
       tion 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.

EXAMPLES
	  >_ string split . example.com
	  example
	  com

	  >_ string split -r -m1 / /usr/local/bin/fish
	  /usr/local/bin
	  fish

	  >_ string split '' abc
	  a
	  b
	  c

   NUL Delimited Examples
	  >_ # Count files in a	directory, without being confused by newlines.
	  >_ count (find . -print0 | string split0)
	  42

	  >_ # Sort a list of elements which may contain newlines
	  >_ set foo beta alpha\\ngamma
	  >_ set foo (string join0 $foo	| sort -z | string split0)
	  >_ string escape $foo[1]
	  alpha\\ngamma

COPYRIGHT
       2019, fish-shell	developers

3.1				 Mar 02, 2021		       STRING-SPLIT(1)

NAME | SYNOPSIS | DESCRIPTION | EXAMPLES | COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=string-split&sektion=1&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help