LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-24-2011, 02:02 AM   #1
johnsee
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Rep: Reputation: 0
How can I list string indexes from an array in ksh ?


How can I list string indexes from an array in ksh ? thanks a lot!
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 01-24-2011, 02:10 AM   #2
juicer
LQ Newbie
 
Registered: Dec 2005
Location: Spain
Distribution: suse
Posts: 4

Rep: Reputation: 0
¿could you be more specific about what are you trying?
 
Old 01-24-2011, 02:19 AM   #3
johnsee
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Original Poster
Rep: Reputation: 0
ok, thanks, for example:

ksh environment:
Code:
arr["a"]=1
arr["b"]=2
arr["c"]=3
I can get "1 2 3" like this:
Quote:
echo ${arr[@]}
but I don't know how to get "a b c", can anyone help me ? thanks a lot !
 
Old 01-24-2011, 02:56 AM   #4
everToulouse
LQ Newbie
 
Registered: Apr 2010
Posts: 18

Rep: Reputation: 5
ksh93
Code:
typeset -A arr
arr[a]=1
arr[b]=2
arr[c]=3
printf '%s\n' "${arr[@]}"
3
2
1
printf '%s\n' "${!arr[@]}"
c
b
a
 
2 members found this post helpful.
Old 01-24-2011, 04:07 AM   #5
johnsee
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Original Poster
Rep: Reputation: 0
everToulouse, thank you very much!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] shell script help: copying directory list into an array and then accessing the array richman1234 Linux - Newbie 6 07-25-2010 11:19 PM
[SOLVED] how to split string into an array/list of lines in C++? rohedin Programming 11 06-06-2010 10:54 AM
ksh script - string comparison sharathkv25 Programming 3 09-19-2008 01:30 AM
To read a string into an array som_kurian Programming 7 12-06-2007 04:39 PM
java test if string in string array is null. exodist Programming 3 02-21-2004 01:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration