New answers tagged

1 vote
Accepted

Ansible: set_fact after successful variable match in array

For me it is also unclear what you are try to achieve, however, regarding your question How to set new value task.type: absent if set.task.type does not match any values from the array? and This ...
user avatar
  • 842
0 votes
Accepted

Grouping commands of if...then statement, including assignation of variable for shell/bash in a single line

The main issue is that option should be specified before operands. Some GNU tools rearrange the given arguments so that this is the case, for convenience (so that the user doesn't have to think about ...
user avatar
  • 276k
0 votes

Combining a variable value and string to form another variable

It works with arrays too! Below is a generalization of @Kusalananda 's approach, but with arrays... declare -a array_a=() declare -n array_b="array_a" for ((i=0;i<=9;i++)); do array_b+...
user avatar
0 votes

Can I determine type of an awk variable?

If the gawk < 4.2(RHEL7 default version: gawk 4.0.2) As fedorqui answer and the gawk 4.2 release note 14. The new typeof() function can be used to indicate if a variable or array element is an ...
user avatar
2 votes

Variable expansion with sh -c executed over ssh

SSH always runs a shell on remote to process the command line you give. See: How do ssh remote command line arguments get parsed $ ssh remote "sh -c 'echo \$HOME'" /root The local shell ...
user avatar
  • 119k
0 votes

Export a value from input variable

shas's answer is good, and I'd like to add that the export attribute of a variable doesn't have to be set after a value is assigned into the variable. This means you can have the exports where they ...
user avatar
  • 1,083
1 vote
Accepted

Export a value from input variable

echo "Please enter REGION to login :" read region && export region echo "Please enter HOST to login :" read HOST && export HOST echo "Please enter Port to ...
user avatar
  • 2,328
2 votes

How to save a result of any command into a variable?

You simply set the variable name to the value of the executed command using a command substitution: $ myVar=$(command-here) or, using the deprecated syntax with backticks (which is somewhat ...
user avatar
  • 15.4k
2 votes

Assigning $* in shell script from args array

Assuming you are using the bash shell, $args would be the equivalent of ${args[0]}, i.e., the first element of the array args. To set the list of positional parameters to the values of the array args, ...
user avatar
  • 276k

Top 50 recent answers are included