Azure CLI with Bash Variables - Part 1

Length: 00:14:07

Lesson Summary:

Bash variables are a valuable tool when working with Azure CLI. With variables we can easily store and retrieve information to help simplify our commands.

In part one of this two-part series, we discuss how to create, assign, and safely access information in variables.

Note: This lesson is intended as an introduction to Bash variables only. If you are excited to learn more, see our other Bash scripting courses for more in-depth discussions.

Important tasks used in this lesson:

  • Creating a variable: name=james
  • Echoing the variable on screen: echo $name
  • Creating a literal variable: name='$superman'
  • Creating a variable based on the output of a command: name=$(echo helloworld)
  • Accessing a variable that may contain whitespace: echo "$name"
  • Specifically accessing a variable: echo ${name}

All commands used in this lesson if you wish to follow along:

name=james
echo $name
echo james
name="james lee"
echo $name
name=james lee

name='$superman'
echo $name
name=$superman
echo $name

name=$(echo helloworld)
echo $name

date=$(date)
echo $date
date

echo $name
name="james lee"
az group create -n $name -l "Australia Southeast"

echo ${name}
echo ${name}hello

This lesson is only available to Linux Academy members.

Sign Up To View This Lesson

Or Log In

Looking For Team Training?

Learn More