Hello.
I have an export of an associative array build using declare -p SOME_ARRAY_NAME > SOME_FILE_NAME.txt.
Producing some thing like
in a text file.
I have a stock of functions which are sourced from /etc/profile.local.
They are accessible for any script.
Moreover the associative array export file was created using one of these functions.
I can create an associative array by calling a function, but the array is not available outside the creative function.
Given a running script, by calling a function, I would like to create an associative array (with the same name as the name in the exported file) and fill it with the exported file.
The associative array should be available in the script calling the function and to any child script.
I would like to use only function and no hard coding.
Any help is welcome.
Try adding -g to the declare statement. The declare statement makes variable local to the function they are created in. The -g switch makes them global.
Use bash's help facility to find out more about declare or any bash built-in.
Hello.
I am running leap 15.1
sudo behavior may differ from other distrib.
I have a file with functions definition
....
function_1 {
echo "Hello world"
}
export -f function_1 This file is sourced by both /etc/bash.bashrc.local and profile.local.
So the functions are... (3 Replies)
I am trying to assign indexes to an associative array in a for loop but I have to use an eval command to make it work, this doesn't seem correct I don't have to do this with regular arrays
For example, the following assignment fails without the eval command:
#! /bin/bash
read -d "\0" -a... (19 Replies)
Hello together,
i make something wrong... I want an array that contains information to associate it for further processing.
Here is something from my bash... You will know, what I'm trying to do.
I have to point out in advance, that the variable $SYSOS is changing and not as static as in my... (2 Replies)
Continuing my quest to learn BASH, Bourne, Awk, Grep, etc. on my own through the use of a few books. I've come to an exercise that has me absolutely stumped.
The specifics:
1. Using ONLY BASH scripting commands (not sed, awk, etc.), write a script to convert a string on the command line to... (22 Replies)
Hi all
I have a problem where i have a large list ( up to 1000 of items) and need to have 2 items pulled from it into variables in a bash script
my list is like the following and I could have it as an array or possibly an external text file maintained separately. Every line is different and... (6 Replies)
I have an associative array named table
declare -A table
table="fruit"
table="veggie"
table="GT"
table="eminem"
Now say I have a variable returning the value highway
How do I find corresponding value GT ??
(this value that I find (GT in this case) is supposed to be the name of a mysql... (1 Reply)
Hi All,
I got stuck up with shell script where i use awk. The scenario which i am working on is as below.
I have a file text.txt with contents
COL1 COL2 COL3 COL4
1 A 500 400
1 B 500 400
1 A 500 200
2 A 290 300
2 B 290 280
3 C 100 100
I could able to sum col 3 and col4 based on... (3 Replies)
Hi
I'm hoping someone can tell me how to extend the scope of an exported function in the korn shell.
I have written a function in a file that I dot in from my .kshrc file and it works fine.
However I would like this function to be available to anyone in a certain group on the machine... (10 Replies)
Like class loader in java, can we make a function loader in shell script, for this can someone throw some light on how internally bash runs a shell script , what happenes in runtime ...
thanks in advance.. (1 Reply)
Hi,
I am trying to make an associative array to use in a popup_menu on a website. Here is what i have:
foreach $entr ( @entries )
{
$temp_uid = $entr->get_value(uid);
$temp_naam = $entr->get_value(sn);
$s++;
}
This is the popup_menu i want to use it in.
popup_menu(-name=>'modcon',... (4 Replies)