Sponsored Content
Top Forums Shell Programming and Scripting Problem when assign the array with the string index Post 302234026 by youareapkman on Tuesday 9th of September 2008 01:59:32 AM
Old 09-09-2008
Problem when assign the array with the string index

I come across the problems when assigning the array in the script below . How to use the array with the 'string index' correctly ? When I assign a new string index , the array elements that are previously assigned are all changed .SmilieSmilieSmilie



Code:
$ array[aa]=211
$ echo ${array[aa]}
211

$ array[bb]=333
$ echo ${array[bb]}
333

$ echo ${array[aa]}
333
$ array[cc]=999
echo ${array[cc]}
999
$ echo ${array[bb]}
999
$ echo ${array[aa]}
999

 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

why the inode index of file system starts from 1 unlike array index(0)

why do inode indices starts from 1 unlike array indexes which starts from 0 its a question from "the design of unix operating system" of maurice j bach id be glad if i get to know the answer quickly :) (0 Replies)
Discussion started by: sairamdevotee
0 Replies

2. UNIX for Dummies Questions & Answers

wh inode index starts from 1 unlike array index (0)

brothers why inode index starts from 1 unlike array inex which starts from 0 its a question from the design of unix operating system of maurice j.bach i need to know the answer urgently...someone help please (1 Reply)
Discussion started by: sairamdevotee
1 Replies

3. UNIX for Advanced & Expert Users

sql variable as array index

hi folks i am facing problom while trying to access sql variable as array index ina unix shell script....script goes as below.. #!/bin/ksh MAX=3 for elem in alpha beeta gaama do arr=$elem ((x=x+1)) Done SQL_SERVER='servername' /apps/sun5/utils/sqsh -S $SQL_SERVER -U user -P pwd -b -h... (1 Reply)
Discussion started by: sudheer157
1 Replies

4. Shell Programming and Scripting

awk array index help

$ cat file.txt A|X|20 A|Y|20 A|X|30 A|Z|20 B|X|10 A|Y|40 Summing up $NF based on first 2 fields, $ awk -F "|" 'BEGIN {OFS="|"} { sum += $NF } END { for (f in sum) print f,sum } ' file.txt o/p: A|X|50 A|Y|60 A|Z|20 (4 Replies)
Discussion started by: uwork72
4 Replies

5. Shell Programming and Scripting

dynamic index for array in while loop

Hi, I'm just trying to use a dynamic index for some array elements that I'm accessing within a loop. Specifically, I want to access an array at variable position $counter and then also at location $counter + 1 and $counter + 2 (the second and third array positions after it) but I keep getting... (0 Replies)
Discussion started by: weak_code-fu
0 Replies

6. Shell Programming and Scripting

Assign words in a string to array

I have a string as "yes why not" I want to create one array variable with contents as one word per place in array.. for above string,the array variable should contain... x="yes,why,not" x = yes x = why x = not Please help me,I am stuck up in the problem since 2 days... (3 Replies)
Discussion started by: uday26
3 Replies

7. Shell Programming and Scripting

Perl and string array problem

#!/usr/bin/perl my @arr=("hello", "how", "are", "you"); $l=length(@arr); print $l; This print 1.Why? How can i print the array size = 4? I want to store these in an array. hello how are you And then i want to access these element through indexing. How can i do this? (4 Replies)
Discussion started by: cola
4 Replies

8. Shell Programming and Scripting

Problem while assign string (words with tab) to a variable

Hi, I have a String(words with tab space) in a file ->file1.txt 0xxxx 11 test $aa$ 8.43 when i read the file and assign to variable value=$(cat file1.txt) echo $value i get the output without tab spaces. 0xxxx 11 test $aa$ 8.43 How to assign string... (2 Replies)
Discussion started by: nanthagopal
2 Replies

9. Shell Programming and Scripting

How to Assign an shell array to awk array?

Hello All, Can you please help me with the below. #!/bin/bash ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1" ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
Discussion started by: Ariean
14 Replies

10. Shell Programming and Scripting

Index problem in associate array in awk

I am trying to reformat the table by filling any missing rows. The final table will have consecutive IDs in the first column. My problem is the index of the associate array in the awk script. infile: S01 36407 53706 88540 S02 69343 87098 87316 S03 50133 59721 107923... (4 Replies)
Discussion started by: yifangt
4 Replies
SPHINXCLIENT(3) 							 1							   SPHINXCLIENT(3)

The SphinxClient class

INTRODUCTION
The SphinxClient class provides object-oriented interface to Sphinx. CLASS SYNOPSIS
SphinxClient SphinxClient Methods o public int SphinxClient::addQuery (string $query, [string $index = "*"], [string $comment = ""]) o public array SphinxClient::buildExcerpts (array $docs, string $index, string $words, [array $opts]) o public array SphinxClient::buildKeywords (string $query, string $index, bool $hits) o public bool SphinxClient::close (void ) o public SphinxClient::__construct (void ) o public string SphinxClient::escapeString (string $string) o public string SphinxClient::getLastError (void ) o public string SphinxClient::getLastWarning (void ) o public bool SphinxClient::open (void ) o public array SphinxClient::query (string $query, [string $index = "*"], [string $comment = ""]) o public void SphinxClient::resetFilters (void ) o public void SphinxClient::resetGroupBy (void ) o public array SphinxClient::runQueries (void ) o public bool SphinxClient::setArrayResult (bool $array_result = false) o public bool SphinxClient::setConnectTimeout (float $timeout) o public bool SphinxClient::setFieldWeights (array $weights) o public bool SphinxClient::setFilter (string $attribute, array $values, [bool $exclude = false]) o public bool SphinxClient::setFilterFloatRange (string $attribute, float $min, float $max, [bool $exclude = false]) o public bool SphinxClient::setFilterRange (string $attribute, int $min, int $max, [bool $exclude = false]) o public bool SphinxClient::setGeoAnchor (string $attrlat, string $attrlong, float $latitude, float $longitude) o public bool SphinxClient::setGroupBy (string $attribute, int $func, [string $groupsort = "@group desc"]) o public bool SphinxClient::setGroupDistinct (string $attribute) o public bool SphinxClient::setIDRange (int $min, int $max) o public bool SphinxClient::setIndexWeights (array $weights) o public bool SphinxClient::setLimits (int $offset, int $limit, [int $max_matches], [int $cutoff]) o public bool SphinxClient::setMatchMode (int $mode) o public bool SphinxClient::setMaxQueryTime (int $qtime) o public bool SphinxClient::setOverride (string $attribute, int $type, array $values) o public bool SphinxClient::setRankingMode (int $ranker) o public bool SphinxClient::setRetries (int $count, [int $delay]) o public bool SphinxClient::setSelect (string $clause) o public bool SphinxClient::setServer (string $server, int $port) o public bool SphinxClient::setSortMode (int $mode, [string $sortby]) o public array SphinxClient::status (void ) o public int SphinxClient::updateAttributes (string $index, array $attributes, array $values, [bool $mva = false]) PHP Documentation Group SPHINXCLIENT(3)
All times are GMT -4. The time now is 04:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy