Read 1-line file and separate into multiple variables

I have one line files with 17 records separated by a semi-colon. I need to create a variable from each record, which I can do via a separate awk for each one, but I know there has to be a better way. Along with pulling out the variable, I need to convert some url coding like a + to a space, etc.

#!/bin/sh
SUBJECT=`nawk 'BEGIN {FS=";"}{print $1;}' 100518-213`
NAME=`nawk 'BEGIN {FS=";"}{print $2;}' 100518-213`
EMAIL=`nawk 'BEGIN {FS=";"}{print $3;}' 100518-213`
...
PORT=`nawk 'BEGIN {FS=";"}{print $17;}' 100518-213`

Now the last 6 records can have multiple entries for the single record and I need to name each one differently. For example, my 17th records is called PORT and it can have multple entries and I need a PORT1 PORT2 PORT3 and so on.

Here is a sample single line record:

100518-213;John+Smith;jsmith@gmail.com;
212-555-1212;js1234;OTHER;Universal+Exports;Normal;I+need+this+
request+completed+as+soon+as+possible+please.;Our+
department+needs+these+added+for+access+to+new+
servers;Please+update+our+group+when+completed.;
All 13-State 9-State;Add Add Delete;Router+Access Mail Other;
;10.1.1.1%2F24 192.168.1.1 10.2.1.1%2F22;23 25 80

If we assume records separated by semicolon, 1 to 17 fields should be something like:

f1	100518-213;
f2	John+Smith;
f3	jsmith@gmail.com;
f4	212-555-1212;
f5	js1234;
f6	OTHER;
f7	Universal+Exports;
f8	Normal;
f9	I+need+this+request+completed+as+soon+as+possible+please.;
f10	Our+department+needs+these+added+for+access+to+new+servers;
f11	Please+update+our+group+when+completed.;
f12	All 13-State 9-State;
f13	Add Add Delete;
f14	Router+Access Mail Other;
f15	;
f16	10.1.1.1%2F24 192.168.1.1 10.2.1.1%2F22;
f17	23 25 80

Some questions:

how the multiple records (in the last 6 as you said) are recognized? separated by space always?

field 15 is null. is that a typo or fields can be null?

what is the final purpose to those variable? how do you going to use them?
perhaps your purpose can be solved in awk itself. (until it is really necessary to go back to the shell.)

Here are the answers to your questions:

how the multiple records (in the last 6 as you said) are recognized? separated by space always? Yes, always separated by a space.

field 15 is null. is that a typo or fields can be null? Yes, fields can be null.

what is the final purpose to those variable? how do you going to use them? The variables will be used to fill in a template.

perhaps your purpose can be solved in awk itself. I am open to any solution.

Ok, Don't have idea about template thing. but regarding your question,

you can do something like:

#!/bin/ksh
eval $(awk 'BEGIN { FS = ";"}
 
function _p (field,cnt)
{
 split(field,arr," ");
 for (n in arr)
 print "var_"cnt"_"n"="arr[n]
}
{ for(i=1;i<=11;i++){ print "var_"i"="$i }
  for(i=12;i<=17;i++){ if ($i != "") {_p($i,i)} else { print "var"i"="$i} }
}' filename) 

## shell part begins


echo $var_1
echo $var_2
echo $var_3
echo $var_4
echo $var_5
echo $var_6
echo $var_7
echo $var_8
echo $var_9
echo $var_10
echo $var_11
echo $var_12_2
echo $var_12_3
echo $var_12_1
echo $var_13_2
echo $var_13_3
echo $var_13_1
echo $var_14_2
echo $var_14_3
echo $var_14_1
echo $var15
echo $var_16_2
echo $var_16_3
echo $var_16_1
echo $var_17_2
echo $var_17_3
echo $var_17_1

Here, filename is the name of the file which contains that one line with 17 records separated by semicolon.

This will create the shell variables in the following manner:

for 1st field var_1
for 2nd field var_2
.....
so on

for multi field, the rule would be:

for 17 field, 1st value, var_17_1 
for 17 field, 2nd value, var_17_2
...
so on

Thank you! I'll give it a try as it looks like it will work for me.