2021年1月24日(日) 10:22 William Park <opengeome...@yahoo.ca>: > [...] But, if separator is string, then it gets messy.
I agree that the split by a (multi-character) string is one of the non-trivial operations in the current Bash. > We shouldn't have to resort to Awk/Python for that. I think a typical reply in this list to this kind of request is just "use Awk/Python". Bash doesn't aim to be a language for writing real programs, so usually you should write the entire program in another language. That said, I feel splitting/joining with a string separator is useful and primitive enough. > How about Python-like string split and string join? What does "Python-like" mean? Is it special compare to common split/join in typical programming languages? > ${parameter...;sep} Is there a background for choosing a semicolon to split words? Zsh has a similar feature with a different syntax: ${(s:sep:)parameter...} ${(j:sep:)parameter...} Actually, we can think of dozens of fancy string operations found in other languages, and the split or the join is merely one of such operations. For example, Zsh has about 50 different flags modifying the expansion results ( see http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags ). We cannot prepare different syntaxes for each of these possible 50 operations, so the question is whether the split/join is so important and essential compared to other possible string operations that it deserves to occupy the semicolon. Recent Bash rather has the parameter expansion form of ${param@flags}, so, if it would be implemented, I guess something like ${parameter@s:sep:} ${parameter@j:sep:} would be a more moderate choice. -- Koichi