|
Ifs
you can manipulate the IFS (internal field separator) - as an example - given that go.dat contains the lines with spaces
# create the array, without manipulating IFS, spaces will break the array
#
set -A lines $(cat go.dat)
for line in "${lines[@]}"; do
echo "'$line'"
done
# create the array, but first change the IFS (set it back - very important)
# after the array is set
#
oIFS=$IFS
IFS=${IFS##?}
set -A lines $(cat go.dat)
IFS=$oIFS
for line in "${lines[@]}"; do
echo "'$line'"
done
### go.dat ###
idno a|PRODUCT|Name|street town postcode|etc|etc|etc|etc
idno b|PRODUCT|Name|street town postcode|etc|etc|etc|etc
idno c|PRODUCT|Name|street town postcode|etc|etc|etc|etc
### end go.dat ###
i realize that does not help your problem (darkness fish already answered) so i thought i would throw my .02 in about IFS - since i have been bitten by that in the past - and it comes in handy quite often
|