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
Bourne-again shell mrsamer UNIX for Dummies Questions & Answers 3 09-30-2006 02:42 AM
bourne shell programming help ganjakh0r Shell Programming and Scripting 1 11-27-2005 08:38 PM
bourne shell not working gillbates Shell Programming and Scripting 6 06-17-2004 04:22 PM
UNix Bourne Shell peter112 Shell Programming and Scripting 3 04-02-2004 10:40 AM
Bourne Shell Scripting Slamo Shell Programming and Scripting 3 05-19-2003 08:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-20-2008
ahmad.diab's Avatar
ahmad.diab ahmad.diab is offline
Registered User
  
 

Join Date: May 2008
Location: Amman Jordan in MEA
Posts: 228
How to define array in Bourne shell , csh & ksh

Dear friends...

Kindly if any one can help me to know the differences in definning & retreiving data from arrays in the sh,csh & ksh.

I always facing problems in this issue.

thanks...

BR
  #2 (permalink)  
Old 09-20-2008
learnbash learnbash is online now
Registered User
  
 

Join Date: Mar 2008
Posts: 96
what u want exactly tell me i'll try my best to do, explain your problem in detail, so i can understand it.

Thanks
Bash
  #3 (permalink)  
Old 09-20-2008
Gee-Money Gee-Money is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 48
There are a few ways to define an array, at least in Bash, and Ksh.

array=(first_member second_member third_member)

if you do it this way, the members are assigned sequentially, meaning they can be referenced by their index, which in this case starts at "0"

# echo ${array[0]}
first_member

# echo ${array[1]}
second_member

# echo ${array[2]}
third_member

Alternatively, you can assign them like this:

# array[2]="hello there"

Now, check the value of of [2]:

# echo ${array[2]}
hello there

To display all of the members of the array, use "*" or "@"
this can be good for for|while|until loops.

# for member in ${array[*]}; do echo $member;done
first_member
second_member
hello there
  #4 (permalink)  
Old 09-21-2008
ahmad.diab's Avatar
ahmad.diab ahmad.diab is offline
Registered User
  
 

Join Date: May 2008
Location: Amman Jordan in MEA
Posts: 228
How to define array in Bourne shell , csh & ksh

Thank you Gee very much , this is what I want...many thanks.

Best Regards
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 03:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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