split into an array? ksh

want to split the path elements into an array.  Perl would be somehting like

@a = split /:/, $ENV{PATH};

How would you do this in ksh?  Is there a simple way to do this without awk, which I have never
used.

Thanks
LVL 1
hank1Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
bpmurrayConnect With a Mentor Commented:
Here - you can still do it in sh:

PATHARR=`echo $PATH | sed -e "s/ /___/g" -e "s/:/ /g"`
set $PATHARR
for DIR in $*
do
   echo "$DIR = `echo $DIR | sed -e 's/___/ /g'`"
done

0
 
bpmurrayCommented:
Something like:

PATHARR=`echo $PATH | sed -e "s/:/ /g"`
set $PATHARR
echo "Count=$#"

Of course, if there are spaces in your pathelements you need to somehow manage these.
0
 
hank1Author Commented:
OK, I surrender.  How do you do this in awk?  There are spaces.
0
 
hank1Author Commented:
OK OK you win.  But I'm going to ask for the awk version.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.