Computing.Net > Forums > Unix > Arrays in Shell scripting

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Arrays in Shell scripting

Reply to Message Icon

Name: sujithk
Date: October 15, 2009 at 15:18:30 Pacific
OS: Windows XP
Subcategory: General
Comment:

H,
When I am using set -A command for creating an array, an error is thrown "bad option(s)"
when the value is negative.
eg.
set -A array_name -1 3 5

can any one provide a solution....
thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: October 15, 2009 at 23:16:17 Pacific
Reply:

The only way I can see to do it, is to declare your array elements using this method:

#!/bin/ksh

typeset array_name[0]=-1
typeset array_name[1]=3
typeset array_name[2]=5

echo ${array_name[0]}


0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Arrays in Shell scripting

Array size in shell script? www.computing.net/answers/unix/array-size-in-shell-script/5761.html

sample shell script using arrays www.computing.net/answers/unix/sample-shell-script-using-arrays/3770.html

loops in shell scripts!!! www.computing.net/answers/unix/loops-in-shell-scripts/5140.html