String manpulation

hi

i have a string as

var="hello1,hello2,hello3"

now i want to display as

1. hello1
2. hello2
3. hello3

where var is not fixed variable which will increase or decrease the words.

any help with shell scripting

As with all thread started in the Shell Programming and Scripting forum, you need to tell us what operating system you're using, what shell you're using, clearly explain what you're trying to do, show us what you have tried to solve the problem on your own, and explain where what you have tried is failing to do what you're trying to do.

In this case, I could make lots of guesses at what you're trying to do. But, since my crystal ball is broken, I'd much prefer that you explain what you're doing instead of me wasting time coming up with solutions for things I might think would be reasonable but probably won't do what you want.

Are you looking for a way to process the contents of a variable (that you will manually change to if you want to process a variable with a name other than var ?

Are you trying to create a function that will take one operand to be processed producing the output you want?

Are you hoping to split the input (variable or operand) into records using <comma> as a record separator? Or can the record separator vary too?

Once you have split the input into records, what output are you trying to produce? Is the last character of each input record supposed to be placed at the start of the input record and follow that with a <period> and a <space> and the remainder of the input record? Can you just pipe the output produced by splitting your input into lines through the nl utility with default options?

i am running on linux machince, and bash script

i have string called

var="sitename1,sitename2,sitename3"

now i have display the output as

output:

1. sitename1
2. sitename2
3. sitename3

I am very glad that you have been able to get the output you wanted.

Please show us how you did it so other people reading your thread can learn from your experience.

Note that I would still also like for you to clearly state your requirements so we know what problem you were trying to solve. But if you show us the code you used to solve your problem, we may be able to deduce your requirements from your code.