1
I have a string that I pass as a parameter, for example :
"2,3,4,5"
To pick up every item of it I make :
#!/bin/bash
for ((i=1; i<=4; i++))
do
echo "$1" | cut -d "," -f $i
done
But I would like to make the loop iterate to the maximum size of the string (which is variable), where each value separated by comma is an item. So how can I count the number of items to insert into for
?
Example: To "2,3,4,5"
you have 4 items.