So what's the story???
I tried to parse a string in a script and later access one of the tokens, but I cannot get it right. Please help!
#! /bin/bash
oIFS="$IFS"
IFS="."
declare -a fields=($1)
echo fields = $fields[0], $fields[1]
IFS="$oIFS"
unset oIFS
word=$fields[1]
echo word = $word
this is put in a script called ww
When called I get
$ ww 64.6.2.3.5.7
fields = 64[0], 64[1]
weight = $fields[1]
but the answer I want is
$ ww 64.6.2.3.5.7
fields = 64, 6
weight = 6