Skip to main content

All Questions

0 votes
2 answers
176 views

Iterating arrays in TCL where array names have a numeric suffix

In TCL, I have a few arrays whose names have a numeric suffix (i.e., whose names end with a number), like below: array set ps0 [ list 0 15.885 1 55.43 1 0.254 2 0.227 3 0.177 ] array set ps1 [ list 0 ...
poppycock's user avatar
2 votes
1 answer
564 views

What is difference between these two declarations of associative arrays in Bash?

I am playing a bit with associative arrays in Bash and I found the following difference when declaring the exact same associative array with and without declare. The code is as follows: #!/usr/bin/env ...
chemacabeza's user avatar
1 vote
1 answer
2k views

How to retrieve items from an array of arrays?

Hello StackExchange pros! I am working on a zsh project for macOS. I used typeset to create three associative arrays to hold values, and a fourth array to reference the individual arrays. Is it ...
jamesrg71's user avatar
0 votes
0 answers
218 views

Unexpected behavior during index assignment in a Bash array [duplicate]

I'm having trouble assigning values to a specific bash index, but apparently only when the index variable is set using a while read loop. Taking this code as a test example: #!/bin/bash read -d '' ...
steinocaro's user avatar
2 votes
2 answers
344 views

I am having difficulties with back-reference in awk

Recently, I am into security logs and want to make it better way on bash-shell. I found out in awk back-references are only stored by 9. But I need to use 10 back-references. Tried awk '{print ...
KeiTheNoop's user avatar
2 votes
1 answer
6k views

how to combine 2 arrays into one associative array

i need to combine ARRAY1 and ARRAY2 into an associative array like ARRAY. i'm using this code: mapfile -t ARRAY1 < <(/bin/awk '{ print $ 1 }' /output/gen_branch) mapfile -t ARRAY2 < <(...
BlackCrystal's user avatar
1 vote
1 answer
212 views

Assoc. Array not being redeclared?

I have a program that acts like a menu. It has an associative array called config such as: declare -A config=( [h]="?" [c]="?" [x]="?" [l]="?" [t]="?" [n]="?" ) In the main loop there's a check to ...
KuboMD's user avatar
  • 439
2 votes
2 answers
2k views

no matches found when using associative arrays in zsh

I am encountering no matches found when using map in zsh: #!/bin/zsh declare -A map=(["8761"]="Eureka服���" ["11001"]="用户微服务") Why would this happen, and how can I fix it? This is the error: ~/source/...
Dolphin's user avatar
  • 761
1 vote
2 answers
2k views

Merge duplicate keys in associative array BASH

I've got an array that contains duplicate items, e.g. THE_LIST=( "'item1' 'data1 data2'" "'item1' 'data2 data3'" "'item2' 'data4'" ) Based on the above, I want to create an associative array that ...
Bart's user avatar
  • 2,314
0 votes
1 answer
41 views

calling associative arrays [closed]

Team, am setting some variables in an associative array but its output is not resulting anything.. any hint?> #/bin/bash #IOEngine="psync" #TestType="read" IOEngine="libaio" TestType="randread" ...
fma abd's user avatar
2 votes
1 answer
5k views

What does declaring a bash array with -A do?

In Example_1, when i have declared city to be an array with declare -A, why is Bangalore output first when the array is printed in the for loop? Bangalore Remote Kolkata Ahmedabad Hyderabad Pune ...
superman's user avatar
41 votes
6 answers
58k views

BASH associative array printing

Is there a way to print an entire array ([key]=value) without looping over all elements? Assume I have created an array with some elements: declare -A array array=([a1]=1 [a2]=2 ... [b1]=bbb ... ...
Dani_l's user avatar
  • 5,127
0 votes
3 answers
7k views

AWK Compare Column 1 from Two Files Print append column to third in output

Looking to compare the first column of two input files that have an identical format. The format looks like the following: FILE1: 0000abc5abc3 GR096 0000def5ae87 GR001 0000cab5aea3 GR001 ...
drfunkenstein's user avatar
4 votes
1 answer
8k views

Ordered by insertion Map in bash

Is there an ordered (by insertion) map in bash? I know there's an associative array data structure in bash, but when iterating over it, the order of the elements is not by insertion. Example below. ...
AlikElzin-kilaka's user avatar
2 votes
1 answer
5k views

Array indexing using "sed"

I am working on one shell script which search directory modified in last 24 hours and then compress them using tar. Folder Search : find /path to log directory/ -maxdepth 1 -type d -mtime +0 ...
Kunal Sonone's user avatar

15 30 50 per page