While replacing external commands in a shell script, I used an array to get rid of awk\'s NF.
Now, since I moved from bash to POSIX sh, I cannot get the
The following code works for me using the Heirloom Bourne Shell:
#!/usr/local/bin/bournesh
# cf. Heirloom Bourne Shell,
# http://freshmeat.net/projects/bournesh/
# http://www.in-ulm.de/~mascheck/bourne/
# use a caret as a pipe symbol to make sure it's a Bourne shell
# cf. http://mywiki.wooledge.org/BourneShell
ls ^ cat 1>/dev/null 2>&1 ||
{ echo 'No true Bourne shell! ... exiting ...'; exit 1; }
IFS=' '
unset RANGE
RANGE="0 1 4 6 8 16 24 46 53"
export IFS RANGE
set -- $RANGE
echo arrayelements: $#
LAST=$#
eval echo "Last element\(replace NF\): \$$#"
Note that IFS is set to a space and there are no double quotes around $RANGE.