🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
3 messages
3 total messages Started by lwv27 Wed, 19 Dec 1990 02:36
Ksh-88e shell array question
#1977
Author: lwv27
Date: Wed, 19 Dec 1990 02:36
40 lines
1300 bytes
I am attempting to turn a ksh variable into an array and then back
into the variable after manipulation.  Here is what I have:

==== Cut here ====

#! /bin/ksh


# Now convert this into an array

IFS=":" ; export IFS

set -A tbl $PATH

size=${#tbl[*]}

i=0
while [ $i -lt $size ] ; do
        echo "Table element $i is ${tbl[$i]}"
        ((i+=1))
done

lst="${tbl[*]}"
lst2="${tbl[@]}"
echo $lst
echo $lst2

exit 0

=== Cut Here ===

The problem is that I cannot figure out how to get the colons back into
the PATH.  What I want to be able to do is to null out entries all together,
so they are not even present.  What I would REALLY like to do is to
have something like an array 'shift' type mechanism I think!
--
Larry W. Virden                 UUCP: osu-cis!chemabs!lwv27
Same Mbox: BITNET: lwv27@cas    INET: lwv27%cas.BITNET@CUNYVM.CUNY.Edu
Personal: 674 Falls Place,   Reynoldsburg,OH 43068-1614
America Online: lvirden
Re: Ksh-88e shell array question
#1979
Author: andrew.d.hay
Date: Wed, 19 Dec 1990 13:07
29 lines
1530 bytes
In article <9012190340.AA20465@lilac.berkeley.edu>, lwv27@CAS.BITNET writes:
> I am attempting to turn a ksh variable into an array and then back
> into the variable after manipulation.  Here is what I have:
> 
[]
> 
> The problem is that I cannot figure out how to get the colons back into
> the PATH.  What I want to be able to do is to null out entries all together,
> so they are not even present.  What I would REALLY like to do is to
> have something like an array 'shift' type mechanism I think!

here's what i do with TERMCAP:

set -A TERMCAP $(infocmp -C)
typeset -i BIT=1
while [[ BIT -le ${#TERMCAP[@]} ]]
do	TERMCAP="${TERMCAP%:? }${TERMCAP[$BIT]} "
	(( BIT += 1 ))
done
set -A TERMCAP "$TERMCAP"
export TERMCAP

hope this helps...

-- 
Andrew Hay		+------------------------------------------------------+
Ragged Individualist	| 	You just have _N_O idea!  It's the difference    |
AT&T-BL Ward Hill MA	|	between _S_H_O_O_T_I_N_G a bullet and _T_H_R_O_W_I_N_G it!     |
a.d.hay@att.com		+------------------------------------------------------+
Re: Ksh-88e shell array question
#1981
Author: Wm E. Davidsen Jr
Date: Thu, 20 Dec 1990 03:35
25 lines
1047 bytes
  Well, when you have the final array of values...

LIM=${A[*]}
n=1
PATH=${A[0]}
while [ $n -lt $LIM ]; do
  PATH=$PATH:${A[$n]}
  let n=n+1
done


- or -

PATH=$(echo ${A[*]} | tr " " ":")

which is a lot simpler, but probably slower because it runs a process
instead of all being in ksh.

Let me know if one of these helps.
-- 
bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
    sysop *IX BBS and Public Access UNIX
    moderator of comp.binaries.ibm.pc and 80386 mailing list
"Stupidity, like virtue, is its own reward" -me
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads