Hi all
I'm building a script that will take an array of values in a file (broken up by commas) and covert the array into a list of values, each preceded by variable identifier.
Example:
Quote:
,10,20,30
,40,50,60
,70,80,90
to
value_1=10
value_2=20
value_3=30
value_4=40
value_5=50
value_6=60
value_7=70
value_8=80
value_9=90
Here is the script logic as I see it:
Quote:
Load file of arrayed values [FILENAME].csv
initiate script variables # don't need help with this area
update the value identifier text that's in the form of a string # don't need help with this area
Use Sed to
find the first comma in the loaded file
replace the comma with a "new line character" then followed by the value identifier string
end Sed command
Save the Sed command exiting status to a variable (was the Sed command successful or did it fail)
Encompass the operation in a while statement that says continue searching for and replacing commas while the Sed command is ending successfully. I.E. repeat the process there are still commas that need to be found and replaced. Otherwise end script
At this point I'm a total noob when it comes to Sed.
Could anyone help me develop a Sed command and a logic structure (the while statement) that will do what I've described above?
Thanks,
Reactor89