I used the following line to create an array of fields from a string:
var=$(echo $FieldName | awk -F";" '{print $1,$2,$3,$4,$5,$6,$7,$8,$9}')
$FieldName
is a string having fields separated by semicolon.
When $FieldName
contains string without whitespace it behaves properly.
The problem is when it contains any whitespace character embedded then the script treats the whitespace as newline.
e.g.:
$FieldName = aa;bcd;cal;da;ea;fa;ga;ha;ia
gives [aa,bcd,cal,da,ea,fa,ga,ha,ia]
which is as expected.
But $FieldName = aa;bcd;cal;da;ea;fa;ga;ha;ia <= ia2
gives [aa,bcd,cal,da,ea,fa,ga,ha,ia] , [<=, , , , , , , , ] and [ia2, , , , , , , , ]
Any ideas?