The associative-array tag has no usage guidance.
1
vote
4answers
55 views
Create an associative array from the output of two commands
I am trying to create user directories based on an imported passwd file, and am trying to load the data into an associative array: array[username]=directory .
I can load the fields into a separate ...
3
votes
3answers
183 views
How to read a properties file into an associative array?
I'd like to read the properties in a properties file into an associative array. How can I do it?
Specifics on what to parse: hash and equal signs. Everything else is a bonus.
Properties file content ...
3
votes
1answer
48 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.
...
1
vote
1answer
58 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
...
1
vote
0answers
14 views
Linux Mint Corners Musical Sequence Associative Array
I am writing a script which uses hot corners to play specific musical notes when hovering in corners, and depending on the musical sequence to execute a specific command.
The script is called with ...
3
votes
2answers
82 views
Set awk array on command line?
I know the -v switch can be used to awk on the command line to set the value for a variable.
Is there any way to set values for awk associative array elements on the command line?
Something like:
...
2
votes
1answer
996 views
Iterate bash associative array in Makefile
$ bash -version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Consider the following shell script:
#!/bin/bash
declare -A PROVS=( ["NL"]=10 ["PE"]=11 ["NS"]=12 ["NB"]=13 ["QC"]=24 ["ON"...
1
vote
1answer
171 views
Combine Bash associative arrays
I am trying make a script that combines arrays on demand. Here is the script:
#! /bin/bash
declare -A code
code=( [H]="h" [E]="e" [L]="l" [P]="p" [M]="m" [E]="e" )
I need to print "help me" - ...
6
votes
2answers
14k views
Associative Arrays in Shell Scripts
I saw a trick for implementing associative arrays in a shell script. For example print array["apples"] could be scripted as echo \$array$key where key=apples.
However, there was no mention of how to ...