Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Splitting $foo on delimiter value



Allen Belk wrote:

>     I am looking for the appropriate method of splitting a string at a set
> delimiter.
> 
> foo=red:white:blue
> 
> I want to seperate these into 3 fields much the way the unix cut command
> would as in:

Try using ${(s.:.)foo}. That should split it on colons.

If you want to write it in a way that is compatible with sh or ksh, you
can stick : in $IFS.

Oliver Kiddle



Messages sorted by: Reverse Date, Date, Thread, Author