parse comma delimited text string
in shell script, I need to know how to get from one comma delimited
text string to many strings. from this: main_string = "onE,Two,Three , fouR,five, six " to these: string1 = "one" string2 = "two" string3 = "three" string4 = "four" string5 = "five" string6 = "six" how to implement this in shell scipt? can anyone help? |
Not pretty, hopefully it'll help you started.
Code:
#~/bin/sh |
You really probably want to use arrays instead of strings.
Code:
#/bin/sh Forrest |
there is no need to use so many cuts as in one of the example solution, and depending on what you want to do, sometimes, there's no need to use arrays. anyway, in bash
Code:
main_string="onE,Two,Three , fouR,five, six " Code:
echo $main_string | awk -F"," '{print $1, $2 ...}' |
Hi forrestt,
thanks for your quick reply. your code suited exactly for my requirement. thanks you very much. -SUN |
All times are GMT -5. The time now is 03:53 AM. |