Bash variables and functions
We'll cover the following...
A variable is a temporary store for a piece of information. There are two actions we may perform for variables: first - setting a value for a variable, second - reading the value for a variable. To read the variable we place its name preceded by a $
sign. To learn more, let’s create a shell script that will backup the home
directory into a zipped (tar.gz
) file.
Press + to interact
#!/bin/bashfilename=homedirbackup_$(date +%Y%m%d).tar.gztar -czf $filename /$home
Here the variable filename
...