Answers for "assigning variables bash"

1

assigning variables bash

gamma_t=540
gamma_new="$(($gamma_t-360))" # get gamma_new by $gamma_t-360 

num2="$(($num1+num2))" 

$((expression))      # you can do expressions like this

$a=5

yourname_$(($a-1)) 	#dynamic varibales. 
#will give
yourname_4
Posted by: Guest on July-20-2021
1

assign a variable in bash

#!/bin/bash
# Naked variables

echo

# When is a variable "naked", i.e., lacking the '$' in front?
# When it is being assigned, rather than referenced.

# Assignment
a=879
echo "The value of \"a\" is $a."

# Assignment using 'let'
let a=16+5
echo "The value of \"a\" is now $a."

echo

# In a 'for' loop (really, a type of disguised assignment):
echo -n "Values of \"a\" in the loop are: "
for a in 7 8 9 11
do
  echo -n "$a "
done

echo
echo

# In a 'read' statement (also a type of assignment):
echo -n "Enter \"a\" "
read a
echo "The value of \"a\" is now $a."

echo

exit 0
Posted by: Guest on May-04-2020

Code answers related to "assigning variables bash"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language