Suppose I have a Unix shell variable as below
variable=abc,def,ghij
I want to extract all the values (abc, def an
abc
def
Try this one.
#/bin/bash testpid="abc,def,ghij" count=`echo $testpid | grep -o ',' | wc -l` # this is not a good way count=`expr $count + 1` while [ $count -gt 0 ] ; do echo $testpid | cut -d ',' -f $i count=`expr $count - 1 ` done