From 8f255659a0e9be1c8f0048358803a4fcd9d3a8ed Mon Sep 17 00:00:00 2001 From: scottdcoulter <66952049+scottdcoulter@users.noreply.github.com> Date: Mon, 31 Aug 2020 09:40:12 -0400 Subject: [PATCH] The "read" command in ksh for arrays takes upper-case -A param; otherwise the command is identical to the bash version. --- SC2206.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SC2206.md b/SC2206.md index 50ac28c..39ddfd9 100644 --- a/SC2206.md +++ b/SC2206.md @@ -27,8 +27,11 @@ printf '%s\n' "$var" | while IFS="" read -r line; do array+=("$line"); done If it's a line with multiple words (separated by spaces, other delimiters can be chosen with IFS), [each of which should be an element](https://stackoverflow.com/a/30212526): ```sh -# For bash and ksh +# For bash IFS=" " read -r -a array <<< "$var" + +# For ksh +IFS=" " read -r -A array <<< "$var" ``` ### Rationale: