The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
compound variable in korn shell ZINGARO Shell Programming and Scripting 0 08-30-2007 11:30 AM
Finding Occurence of comma in a Variable ( KORN Shell) DeepakXavier Shell Programming and Scripting 2 11-14-2005 04:44 AM
Compound indirect variable references tkrussel UNIX for Advanced & Expert Users 5 08-21-2005 10:03 AM
Trying to use 'compound variable' in a script irina Shell Programming and Scripting 1 01-29-2004 10:33 PM
Trying to use 'compound variable' in a script neemic Shell Programming and Scripting 3 01-16-2004 07:07 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-30-2007
ZINGARO ZINGARO is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 36
compound variable in korn shell

in a text " Korn Shell Unix programming Manual 3° Edition"

i have found this sintax to declare a compoud variable:

variable=(
[datetype] fild1 [=value]
[datetype] fild1 [=value]
)

but this sintax in ksh and sh (HP-UNIX) not work...

why?? exist another solution for this type of variable ???
  #2 (permalink)  
Old 08-30-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
That syntax is correct. For ksh93 only.

try:
Code:
a="one.two"
echo $a
one.two
echo ${a%.*}
one
echo ${a#*.}
two
  #3 (permalink)  
Old 10-02-2007
ZINGARO ZINGARO is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 36
i cut the page.. read this

Compound Variables
The Korn shell also supports compound variables, which are similar to structures or records in other
languages, that is a meta-datatype which is a group of related values, each of which can have a different
data type. The syntax for declaring compund variables is:

compound_variable=(
[datatype] field1[=value]
. . .
[datatype] fieldn[=value]
)

For example, we can use a compound variable to manage employee information:
$ employee=(
typeset name=Allenby
integer id=1243
float salary=9000.50
)

The syntax to display the value of a compound variable field is:

${compound_variable.field}
Here we access the employee compound variable:
$ print $employee
( typeset -E salary=9000.5 name=Allenby typeset -i
id=1243 )
$ print ${employee.name}


in HP/ksh not work....


and this :

$ typeset -AE exchange_rate
$ exchange_rate["DM"]=1.7
$ exchange_rate["FF"]=.15
$ exchange_rate["AS"]=.04
To display a list of associative array subscripts:
${!variable[*]} or ${!variable[@]}

not work ???
  #4 (permalink)  
Old 10-02-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
You need ksh93 (not ksh88):

Code:
$ Version M-11/16/88i
$ typeset -AE exchange_rate
ksh: typeset: bad option(s)
Code:
$ /usr/dt/bin/dtksh
$ print ${.sh.version}
Version M-12/28/93
$ typeset -AE exchange_rate
$ exchange_rate[DM]=1.7
$ exchange_rate[FF]=.15
$ exchange_rate[AS]=.04
$ print ${exchange_rate[FF]}
0.15
$ print ${exchange_rate[@]}
1.7 0.15 0.04
$ print ${!exchange_rate[@]}
DM FF AS
  #5 (permalink)  
Old 10-03-2007
ZINGARO ZINGARO is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 36
OK. !!!
exist a more info or manual to see a difference from ksh ???

( i try sobstitute the declare in my shells but the shell return more error in other point !!!!)

i serach with emule "dtksh" but i not found result .....
  #6 (permalink)  
Old 10-03-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
HP's version of ksh (ksh88) does not support compound variables. You will have to do one of these:
1. See if any of these downloads are for you:
KornShell Software
2. See if zsh will work for you:
ZSH - THE Z SHELL
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0