Sponsored Content
Full Discussion: Problem with Array in Script
Homework and Emergencies Emergency UNIX and Linux Support Problem with Array in Script Post 302440507 by forquare on Tuesday 27th of July 2010 11:12:20 AM
Old 07-27-2010
If you wanted to use Bash instead of Korn (and on some systems sh is Bash), you'll want to define arrays like this:
Code:
declare -a entityArray

And use them like this:
Code:
${#entityArray[*]} #Gets number of elements in array
${entityArray[$x]} #Gets x'th element is array
${entityArray[*]} #Gets all elements in array

Ben
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

array problem

Dear Experts, please help me out once again my array concepts is not very clear i have one text file like. 1|usa|hh 2|usa|ll 3|usa|vg 4|uk|nn 5|uk|bb 6|kuwait|mm 6|kuwait|jkj 7|dubai|hh i want to store the third fied of a text file in he array and after that it should give me some... (6 Replies)
Discussion started by: shary
6 Replies

2. Shell Programming and Scripting

problem with array=($(find ....)

hi, I get a *.dat files list in an array using: array=($(find . -name "*.dat")) the problem is that when a filename contains spaces, each space-separated token of the filename is in a different element of array. For instance if I have: x@x:~/tmp$ ls *.dat test1.dat test 2.dat ... (1 Reply)
Discussion started by: jul
1 Replies

3. Shell Programming and Scripting

Array problem

I am using /bin/ksh for this problem. I have created some arrays with variable names as the array names: cnt=1 { while read myline; do tempmeas="${meas%%;*}" cto="${meas#*;}" tempstream=$stream # wholemeas holds the name of the array # each array name... (0 Replies)
Discussion started by: ajgwin
0 Replies

4. Shell Programming and Scripting

bash array problem

hi friends., i have two files yy.dat and mm.dat containing 110 elements in each if i read them into variables it is just showing only 4 elements instead of 110 elements My script is like this ################################## /bin/bash declare -a yy=(`cat yy.dat`) echo "No of values in... (1 Reply)
Discussion started by: yagnesh
1 Replies

5. Programming

Problem with array of pointers

Hi All, I am using the array of pointers and storing the address of string.This is a global list. So i am using extern to give the reference of this list to another file and using reading the data from this string. But list is being corrupted and string is missing some characters in... (2 Replies)
Discussion started by: lovevijay03
2 Replies

6. Programming

Help on some array problem!!

i have no idea how to make a text file abc efg hij klm nop qrs to be a array such as, arr to be "abc efg" arr "hij kml" etc..... in C (2 Replies)
Discussion started by: tyckelvin1
2 Replies

7. Shell Programming and Scripting

Array reference problem

i have a variable MYHOST that has my host name.depending on the host i have an array like A_<hostname>.Everytime i need to append the hostname to A_ to get the array.but in the shell script i am nt able to access the members of that array. code of what i hav done: export temp=A_$MYHOST for... (15 Replies)
Discussion started by: niteesh_!7
15 Replies

8. Shell Programming and Scripting

Using awk array problem

I am trying to map values in the input file, where 2nd column depends on the specific value in the 1st column. When 1st column is A place 1 into 2nd column, when it is B, place 2, when C place 3, otherwise no change. My input: U |100|MAIN ST |CLMN1|1 A |200|GREEN LN |CLMN2|2 1 |12... (4 Replies)
Discussion started by: migurus
4 Replies

9. UNIX for Dummies Questions & Answers

Bsub array problem

I'm trying to run some computations on a cluster and have found that a bsub array is what I need.. So I tried running a simple example I found bsub -J "myArray" echo "Job \$LSB_JOBINDEX" This should create 10 jobs that output "Job 1" "Job 2" .. etc. But when I run this from afs space I get... (1 Reply)
Discussion started by: ehj
1 Replies

10. UNIX for Beginners Questions & Answers

Array problem in Bash Script

I am trying to write a Bash Script using a couple of arrays. I need to perform a countdown of sorts on an array done once daily, but each day would start with the numbers from the previous day. This is what I'm starting with : #!/bin/bash days=(9 8 7 6 5) for (( i = 0 ; i < ${#days} ; i++... (4 Replies)
Discussion started by: cogiz
4 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy