This question already has answers here:
Dynamic variable names in Bash
(19 answers)
How can I generate new variable names on the fly in a shell script?
(6 answers)
Closed 2 years ago.
I have a variable that points at a file called point.c
I would like to temporarily append "A" to "_SRCS" so I can rename the variable and use it in a function as "SRCS".
A_SRCS=point.c
pro="A B"
for x in $pro
do
SRCS=${${x}"_SRCS"}
echo $SRCS #(will point to a function later on..)
done
Related
This question already has answers here:
Dynamic variable names in Bash
(19 answers)
variable variables in sh or dash
(1 answer)
Closed 4 months ago.
I'm trying to get a value of the variable by double substituting inside the string as follows
i=1
df1 ='date_col'
X='value of the string is $df$i'
But getting invalid substitution error
I need the output as follows
echo $X
value of the string is date_col
This question already has answers here:
Loop through a comma-separated shell variable
(10 answers)
Loop through an array of strings in Bash?
(21 answers)
Splitting a comma separated string into multiple words so that I can loop through each word
(4 answers)
Closed 1 year ago.
host_list=abc#xyz.com,cde#xyz.com,zbe#xyz.com
I want to write loop in bash script to scroll through each of this host_list & try to grep a particular string 'abc#xyz.com'. if its present then return yes or no
This question already has answers here:
Dynamic variable names in Bash
(19 answers)
How can I generate new variable names on the fly in a shell script?
(6 answers)
Closed 2 years ago.
I would like to do in bash something I was doing with perl years ago
$4 (value from a script) can have the value "S" or "U"
I have:
DirectoryU="$Directory/*.$2"
DirectoryS="$Directory/area $3/*.$2"
and I want to define "DirectoryC" to something like:
DirectoryC=Directory$4
but there I dont want DirectoryC=DirectoryU (or DirectoryS) I want DirectoryC to have the value of DirectoryU (or DirectoryS) so after I can base my script on $DirectoryC ...
Does it make sense?
This question already has answers here:
Indirect variable assignment in bash
(7 answers)
Dynamic variable names in Bash
(19 answers)
Closed 3 years ago.
I want to set FOO="myvar" and set myvar to another variable. Not sure if that makes sense. Example below.
FOO="myvar"
BAR="true true false"
eval $FOO=$BAR <==== Problem line
echo $myvar
I want the last line to print "true true false"
This question already has answers here:
Bash insert subnode to XML file
(2 answers)
Environment variable substitution in sed
(12 answers)
Difference between single and double quotes in Bash
(7 answers)
Closed 5 years ago.
I tried to add some string between strings.
I want to add "themev2" to
<SEC_FLOATING_FEATURE_COMMON_CONFIG_CHANGEABLE_UI></SEC_FLOATING_FEATURE_COMMON_CONFIG_CHANGEABLE_UI>
so that the result is
<SEC_FLOATING_FEATURE_COMMON_CONFIG_CHANGEABLE_UI>themev2</SEC_FLOATING_FEATURE_COMMON_CONFIG_CHANGEABLE_UI>
I tried to use
lama="<SEC_FLOATING_FEATURE_COMMON_CONFIG_CHANGEABLE_UI></SEC_FLOATING_FEATURE_COMMON_CONFIG_CHANGEABLE_UI>"
baru="<SEC_FLOATING_FEATURE_COMMON_CONFIG_CHANGEABLE_UI>themev2</SEC_FLOATING_FEATURE_COMMON_CONFIG_CHANGEABLE_UI>
sed -i 's/$lama/$baru/g' /system/etc/floating_feature.xml;
But it does not work :(