Hi
I have a line/string as follows:
A=" 3498 NORDEA - INDX LINKED NORY"
which was converted into an array of characters:
p321$ echo "${ARR[*]}"
3 4 9 8 N O R D E A - I N D X L I N K E D N O R Y
When I am trying print this array there are blank spaces between the letters. I am not sure why.... Is there a way to print this array so no blanks will be added btw the latters, another words how to convert this array to the original format (no blank between letters)
Thanks a lot for any advice....
doing 'man ksh' yields the following:
The shell supports a one-dimensional array facility. An ele-
ment of an array variable is referenced by a subscript. A
subscript is denoted by a [, followed by an arithmetic
expression (see Arithmetic Evaluation below) followed by a
]. To assign values to an array, use set -A name value ....
The value of all subscripts must be in the range of 0
through 4095. Arrays need not be declared. Any reference to
a variable with a valid subscript is legal and an array will
be created if necessary. Referencing an array without a sub-
script is equivalent to referencing the element 0. If an
array identifier with subscript * or @ is used, then the
value for each of the elements is substituted (separated by
a field separator character).
Tried resetting IFS to nothing?
If you just want to remove the spaces, send it the 'tr', and have it delete them.
echo "s t r i n g "| tr -d ' '
bd - I hope this helps.
use awk
awk 'BEGIN{
A=" 3498 NORDEA - INDX LINKED NORY"
m=split(A,a,"")
for(i=1;i<=m;i++){
print a
}
}
or
# echo "3498 NORDEA - INDX LINKED NORY" | awk 'BEGIN{FS=""}{for(i=1;i<=m;i++)print $i}'
string=$( printf "%s" "${ARR[@]}" )