Sponsored Content
Top Forums Shell Programming and Scripting Bash Array connectin to another Array Post 303003471 by batchenr on Thursday 14th of September 2017 07:48:15 AM
Old 09-14-2017
thanks for the replay but i dont think its it.
i do belive it should be with dictionary.

doing this is too specific with the key1 key2

Code:
declare -A array_name

array_name["Key1"]="Value1"
array_name["Key2"]="Value2"
array_name["Key3"]="Value3"
array_name["Key4"]="Value4"

for testkey in Key3 Key1
do
   echo "${array_name[$testkey]}"
done

i want it to go throw all the account codes and know that code=name
and echo the name
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash array

I'm trying to move files based on a certain day..my question is on array's, what's wrong with the way I'm stepping through the array? what i have gives me syntax errors..any ideas...so far I have #! /bin/bash sun_d=`cal |grep -v |awk '{printf " " $1}' ` echo "$sun_d" ls -l... (1 Reply)
Discussion started by: gubten
1 Replies

2. Shell Programming and Scripting

create array holding characters from sring then echo array.

Hi, I wish to store $string1 in $string1array a character in each array element. Then i wish to echo the entire array to the screen so that it reads as the normal string again. I have been trying with the code below but does not work. Please help... To put string into array: ... (5 Replies)
Discussion started by: rorey_breaker
5 Replies

3. 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

4. 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

5. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

6. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

7. 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

8. Shell Programming and Scripting

Array in Bash!

sorry I am new to the bash scripting since I was used to c shell programming. I am writting a script in bash for which I have to create an array in bash. I was able to do parse one variable through command line by doing": Lets say the below code is part of temp.bash and is called like: temp.bash... (5 Replies)
Discussion started by: dixits
5 Replies

9. 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

10. 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
GOPHER_PARSEDIR(3)							 1							GOPHER_PARSEDIR(3)

gopher_parsedir - Translate a gopher formatted directory entry into an associative array.

SYNOPSIS
array gopher_parsedir (string $dirent) DESCRIPTION
gopher_parsedir(3) parses a gopher formatted directory entry into an associative array. While gopher returns text/plain documents for actual document requests. A request to a directory (such as /) will return specially encoded series of lines with each line being one directory entry or information line. PARAMETERS
o $dirent - The directory entry. RETURN VALUES
Returns an associative array whose components are: o type - One of the GOPHER_XXX constants. o title - The name of the resource. o path - The path of the resource. o host - The domain name of the host that has this document (or directory). o port - The port at which to connect on host. Upon failure, the additional data entry of the returned array will hold the parsed line. EXAMPLES
Example #1 Hypothetical output from gopher://gopher.example.com/ 0All about my gopher site. /allabout.txt gopher.example.com 70 9A picture of my cat. /pics/cat.png gopher.example.com 70 1A collection of my writings. /stories gopher.example.com 70 hThe HTTP version of this site. URL:http://www.example.com gopher.example.com 70 1Mirror of this site in Spain. / gopher.ejemplo.co.es 70 iWelcome to my gopher site. error.host 1 iPlease select one of the options above error.host 1 iSend complaints to /dev/null error.host 1 iLong live gopher! error.host 1 In the example above, the root directory at gopher.example.com knows about one DOCUMENT identified by 0 located at gopher://gopher.exam- ple.com:70/allabout.txt. It also knows about two other directory (which have their own listing files) at gopher://gopher.exmaple.com:70/stories and at gopher://gopher.ejemplo.co.es:70/. In addition there is a binary file, a link to an HTTP url, and several informative lines. By passing each line of the directory listing into gopher_parsedir(3), an associative array is formed containing a parsed out version of the data. Example #2 Using gopher_parsedir(3) <?php $directory = file("gopher://gopher.example.com"); foreach($directory as $dirent) { print_r(gopher_parsedir($dirent)); } ?> The above example will output: Array ( [type] => 0 [title] => All about my gopher site. [path] => /allabout.txt [host] => gopher.example.com [port] => 70 ) Array ( [type] => 9 [title] => A picture of my cat. [path] => /pics/cat.png [host] => gopher.example.com [port] => 70 ) Array ( [type] => 1 [title] => A collection of my writings. [path] => /stories [host] => gopher.example.com [port] => 70 ) Array ( [type] => 254 [title] => The HTTP version of this site. [path] => URL:http://www.example.com [host] => gopher.example.com [port] => 70 ) Array ( [type] => 1 [title] => Mirror of this site in Spain. [path] => / [host] => gopher.ejemplo.co.es [port] => 70 ) Array ( [type] => 255 [title] => Welcome to my gopher site. [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Please select one of the options above. [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Send complaints to /dev/null [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Long live gopher! [path] => [host] => error.host [port] => 1 ) PHP Documentation Group GOPHER_PARSEDIR(3)
All times are GMT -4. The time now is 06:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy