0
votes
1answer
29 views

replacing subString in an Array BASH

what i got: array[0]="Programm is Running" array[1]="programm is down" what i want: array[0]="Programm is \e[0;32mRunning\e[0m" array[1]="programm is \e[0;31mDown\e[0m" this will make things a ...
0
votes
0answers
59 views

Bash, transforming a string list of words in a array

Sorry if I post a question on a topic discussed dozens of times. I'm trying to work on an element of an associative array and assign it to an array. I know that in bash associative arrays are ...
1
vote
1answer
42 views

can't seem to populate bash array with new elements using '+=' operator

Like the title says. Trying to populate an array from zenity checklist output. Here is the function I want to run, but fails: function fSongType() { mType=$(zenity --list --title "Random song ...
0
votes
2answers
69 views

In associative arrays, assigning index and value at the same time

In a bash script I found the following but though it works I cannot understand its logic REMOTESNAPS+=(["$FS"]=" $SNAP") The statement above adds an element to the associative array REMOTESNAP by ...
1
vote
1answer
51 views

How woulld I add $OPTARGs from one arg to an array

So I'm trying to add values from an optarg to an array. I've got: arrays=() while getopts a: args; do case $args in a) arrays+=$OPTARG;; esac done echo $arrays[@] When I run the script, ...
4
votes
3answers
261 views

Spawning multiple parallel wgets and storing results in a bash array to be pretty printed when all wgets are done

I have a long list of urls on my own website listed in a carriage return seperated text file. So for instance: http:/www.mysite.com/url1.html http:/www.mysite.com/url2.html ...
0
votes
2answers
167 views

Array support for the original bash in MacOS 10.4.0?

I'm writing a bash script using simple array operations like: testarray=("First Name" "Second Name" "Third Name") ; for i in "${testarray[@]}" ; do echo "$i" ; done What bash version number came ...
10
votes
5answers
28k views

Test if element is in array in bash

Is there a nice way of checking if an array has an element in bash (better than looping through)? Alternatively, is there another way to check if a number or string equals any of a set of predefined ...