A record contains 50 fields separated by "~". I need to assign each of these fields to different variables. Following is the shell script approach I tried.
As you haven't shown us the complete requirement here so little difficult to say how you wanted to use these 50 variables. But wanted to highlight here for these kind of requirements only we have array concept, here is an example for same where you could get an array with all the elements in the lines and if you wanted to use any specific position of that array's element you could do so.
I wanted to use specific variable names for better readability. For example, the actual field name is more readable than an array name with index. Hence did not go for array.
Another approach I tried is using the
read
command.
echo ${RECORD} | read VAR1 VAR2 VAR3
It works with space delimiter. I'm not sure how to handle this for other delimiters.