doubt - array related


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting doubt - array related
# 1  
Old 01-28-2011
doubt - array related

hi,

Can someone give me some clues how will i be able to check if variable is matching a list of values. As of now im able to do it with 'if' , 'for' and 'arrays', if there is any easy method to do it, please let me know. switch case is also not needed.

./file.sh read

LIST = "read read1 read2"

the LIST is expected to increase in future.


cheers,
Balaji
# 2  
Old 01-28-2011
Hi,

Please find herewith a similar thread which might provide the info you're after:

https://www.unix.com/shell-programming-scripting/20375-bourne-shell-arrays.html

I assume you mean Bourne shell. Bash has great array support, a swift google will help you there.


Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies

2. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

3. Shell Programming and Scripting

Help related to clearing of shell scripting doubt

Hello Gurus, Can anybody please help me to understand as what does this lines(Marked in bold) does: _TABLESPACE_OFFLINE=`cat ${_tmp_res} | grep -iv "online" | grep -v "^*$" | grep -iv "SQL>"` ------->1 if ;then _tmp_tablespace_status=1 ... (1 Reply)
Discussion started by: hitesh1907
1 Replies

4. Shell Programming and Scripting

Query related to references in array in Perl

Hi All I have a doubt and want to be cleared I am using @array = (10, 20); $rarray = \@array; #print "$rarray\n"; #print "@$rarray\n"; $rr= \$array; #print $$rr; $rr++; print $$rr; As you can see the $rr contains the reference to the first element of the array , now as the... (5 Replies)
Discussion started by: parthmittal2007
5 Replies

5. Shell Programming and Scripting

need downloading related help...but its not related to unix

Hi All, I am trying to dowmload the zip file "zkManageCustomers.zip " but i dont have access. Can anyone help me to download this file See the below link- http://www.ibm.com/developerworks/opensource/library/wa-aj-open/index.html?ca=drs- Please help me as early as... (1 Reply)
Discussion started by: aish11
1 Replies

6. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

7. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

8. Shell Programming and Scripting

Doubt on Array creation

Hi, Suppose partition=9 then by checking that partition variable value ,i need to create an array variable which must contain 9 values and must be repeative as a,b,g,h,a,b,g,h,a... Could you please help me in creating as above way.. Thanks in Advance, Mansa (3 Replies)
Discussion started by: mansa
3 Replies

9. Programming

Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ... (4 Replies)
Discussion started by: kmehta
4 Replies

10. UNIX for Dummies Questions & Answers

some doubt related to SAR

hi i am trying to monitor server activity through SAR command when i run $ sar -u 1 20 i get output as time , %usr , %sys , %io , %idle i want to know what is %usr like its all user processes for on that server or just process of current user i think this indicates all server processes not... (1 Reply)
Discussion started by: zedex
1 Replies
Login or Register to Ask a Question