Skip to content

Latest commit

 

History

History

0x03-shell_variables_expansions

img

shell variable expansion

Intro

Have you ever found yourself writing a shell script and wanting to incorporate the value of a variable into a command or string? Or maybe you've wanted to manipulate the value of a variable before using it in your script. If so, then you'll want to learn about shell variable expansion. Lets take a deep dive into this powerful feature of the shell and explore some of the various ways you can use it to make your scripts more flexible and efficient

Resources

Read or watch.

  1. Expansions
  2. Shell arithmetic
  3. Variables
  4. Shell init files
  5. The alias command
  6. Technical writting

Man or Help

  • printenv
  • set
  • unset
  • export
  • alias
  • unalias
  • .
  • source
  • printf

Learning objectives

By the end of this project, you should be able to explain to anyone Without the help of google the following concepts

General

  • What happens when you type $ ls -l *.txt

Shell intialization files

  • What are the /etc/profile file and the /etc/profile.d directory
  • What is the ~/.bashrc file

Variables

  • What is the difference between a local and a global variable
  • What is a reserved variable
  • How to create, update and delete shell variables
  • What are the roles of the following reserved variables: HOME, PATH, PS1
  • What are special parameters
  • What is the special parameter $??

Expansions

  • What is expansion and how to use them
  • What is the difference between single and double quotes and how to use them properly
  • How to do command substitution with $() and backticks

Shell Arithmetic

  • How to perform arithmetic operations with the shell

The alias command

  • How to create an alias
  • How to list aliases
  • How to temporarily disable an alias

Other help pages

  • How to execute commands from a file in the current shell

More info

Read your /etc/profile, /etc/inputrc and ~/.bashrc files.

Look at some files in the /etc/profile.d directory.

Note: You do not have to learn about awk, tar, bzip2, date, scp, ulimit, umask, or shell scripting, yet.

Quizes

Quiz