I have a variable that has a value like thisline=dog,/path1,/path2What I want is to create a variable from the value; i.e dog should be the variable and want to get the below output:dog=/path1,/path2dog1=/path1dog2=/path2Similarly if I have line=bull,/val1,/val2 I need the below outputbull=/val1,/val2bull1=/val1bull2=/val2Note that line will have only three values separated by commas.
Create text corresponding to multiple variable assignments from a single variable
shell;text processing;variable
I think that's the thing you're trying to do: line='dog,/path1,/path2'IFS=', ' read -r -a dog <<< $lineecho $dogdogecho ${dog[1]}/path1echo ${dog[2]}/path2 This assumes that your shell is bash.