Sponsored Content
Top Forums Shell Programming and Scripting '*' vs. '@' in Korn Shell Array Variables Post 302672495 by Clovis_Sangrail on Monday 16th of July 2012 12:08:29 PM
Old 07-16-2012
'*' vs. '@' in Korn Shell Array Variables

In order to use the shellcurses functions described at:

Shell Curses function library

I am learning about ksh, which has arrays. My trusty Kochan & Wood book says that for any Korn Shell array AR :

${AR[*]} expands to all the defined array elements, and

${#AR[*]} expands to the number of array elements.

But the example programs from the above website use '@' instead of '*' in the two expressions above. Both seem to work. My sample program:

Code:
#!/usr/bin/ksh93.att
source /home/lc25487/ksh/shellcurses.ksh
 
MENU[0]="First Menu Line"
MENU[1]="Second Menu Line"
MENU[2]="Third Menu Line"
ITEMCNT=${#MENU[@]}
ITEMCNTSTAR=${#MENU[*]}
ALLITEMS="${MENU[@]}"
ALLITEMSSTAR="${MENU[*]}"
echo
echo ITEMCNT = $ITEMCNT
echo ITEMCNTSTAR = $ITEMCNTSTAR
echo ALLITEMS = $ALLITEMS
echo ALLITEMSSTAR = $ALLITEMSSTAR
echo

produces the following output (on AIX 6.1):

==========
lipossrp01ga:/home/lc25487/ksh $ ./t2.ksh

ITEMCNT = 3
ITEMCNTSTAR = 3
ALLITEMS = First Menu Line Second Menu Line Third Menu Line
ALLITEMSSTAR = First Menu Line Second Menu Line Third Menu Line

lipossrp01ga:/home/lc25487/ksh $
==========

What (if anything} is the difference between the usage of @ or * ?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Oracle To Korn Shell Array

I'm attempting to populate an array in ksh using the following command: set -A $(SELECT_INVOICE | sed '/^$/d') SELECT_INVOICE is a function that executes the SQL query. Problem: Some of the invoice numbers have alpha characters with spaces(example: OVEN MICRO). The Korn shell is treating... (1 Reply)
Discussion started by: kdst
1 Replies

2. Shell Programming and Scripting

korn shell array?

I read it is possible to provide values for an array with the -A option to the read statement; however, I have not been able to get this to work. When I execute a script with the -A option to the read statement, the shell complains that it is an illegal option. If this works, can someone provide... (5 Replies)
Discussion started by: cstovall
5 Replies

3. Shell Programming and Scripting

Variables Naming in Korn Shell

Hi every body, I want to know what is the different between the following: $VAR1 ${VAR2} "${VAR3}" Are they equivalent? Thanks in advance (1 Reply)
Discussion started by: aldowsary
1 Replies

4. Shell Programming and Scripting

I can't decalar an array in my korn shell script

I have a script that contains #!/usr/bin/ksh set -A X 'hallo' 'world' echo ${X} echo ${X} when I execute it I get an errror message sh ./test.ksh ./test.ksh: -A: bad option(s) but if I do this at the command prompt I am able to create it set -A myarray '1' '2' '3' echo ${myarray}... (4 Replies)
Discussion started by: zilla30066
4 Replies

5. Shell Programming and Scripting

How to: Parse text string into variables using Korn shell

I am writing a script to keep check on free disk space, and I would like to find a way to parse $LINE (see code below) into a numeric value (for free disk space percentage) and a string value (for mount point). If possible, I would like to avoid sed or any additional use of awk since I am not very... (7 Replies)
Discussion started by: shew01
7 Replies

6. UNIX for Advanced & Expert Users

Accessing PL/SQL OUT variables in Korn Shell Script

Hello All, I was just wondering if there is any direct way to access PL/SQL OUT variables from Korn Shell Script. I could already figure out how to return a single value back from PL/SQL to Shell Script (using bind variable). But, what if we want to return multiple values? One option I... (4 Replies)
Discussion started by: bright_future
4 Replies

7. Shell Programming and Scripting

need help with korn shell array

I have a korn shell script that reads a file with just one column in the file. If the file has more than 5 entries it is split using split -5. This means that is we have 15 entries I will end up with 3 files with 5 entries/lines in each and if I have 23 entries I will end up with 5 files with the... (2 Replies)
Discussion started by: kieranfoley
2 Replies

8. Shell Programming and Scripting

Generate array name at run time Korn shell

Hi, I am trying to define number of array based on constant derived during execution phase of a script. Here is what i am trying.. #First Part, Get LUN input from User lun_count=4 count=0 set -A my_lun while : do while ]; do read L?"Enter Lun "$count" Number:" ... (2 Replies)
Discussion started by: harris2107
2 Replies

9. Shell Programming and Scripting

floating point variables korn shell

Hi I'm not using Korn93 but want to use floating point variable. Is there any solution to do that ? thx for help. ---------- Post updated at 02:28 PM ---------- Previous update was at 12:38 PM ---------- I have the following peace of code: for n in `cat log.January.1.array` do ... (3 Replies)
Discussion started by: presul
3 Replies

10. Shell Programming and Scripting

Korn Shell Array maximum value less than other value

I have a text file with several key words that I am trying to isolate. I have grepped for the unknowns in the text file, but each unknown has a corresponding location. I have created an array that holds all the unknowns and another array that holds all of the locations and compares them based on... (12 Replies)
Discussion started by: ther2000
12 Replies
Shell(3)							  LessTif Manuals							  Shell(3)

NAME
Shell - Shell widget from X Toolkit SYNOPSIS
#include <X11/Shell.h> DESCRIPTION
Shell is a widget which is defined in the X Toolkit. We document its existence here for completeness. Please refer to the X Window System documentation for the real information regarding this widget. X RESOURCES
Name Class Type Default Access -------------------------------------------------------------------------------- XtNx XtCPosition Position NULL CSG XtNy XtCPosition Position NULL CSG XtNdepth XtCDepth Int NULL CSG XtNcolormap XtCColormap Colormap NULL CSG XtNancestorSensitive XtCSensitive Boolean NULL CSG XtNallowShellResize XtCAllowShellResize Boolean NULL CSG XtNgeometry XtCGeometry String (null) CSG XtNcreatePopupChildProc XtCCreatePopupChildProc Function NULL CSG XtNsaveUnder XtCSaveUnder Boolean NULL CSG XtNpopupCallback XtCCallback Callback NULL CSG XtNpopdownCallback XtCCallback Callback NULL CSG XtNoverrideRedirect XtCOverrideRedirect Boolean NULL CSG XtNvisual XtCVisual Visual NULL CSG XtNx XtNy XtNdepth XtNcolormap XtNancestorSensitive XtNallowShellResize XtNgeometry XtNcreatePopupChildProc XtNsaveUnder XtNpopupCallback XtNpopdownCallback XtNoverrideRedirect XtNvisual CLASS HIERARCHY
Object(3) Rect(3) UnNamedObj(3) Core(3) Composite(3) Shell(3) CALLBACKS
CONVENIENCE FUNCTIONS
SEE ALSO
LessTif Project October 1998 Shell(3)
All times are GMT -4. The time now is 01:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy