Hands-on task
Move the server name into a variable
The server name web-01 is written three times in the script /root/deploy.sh. Deploys now go to web-02, and later the name will change again — editing three places every time is a pain, and it's easy to miss one.
At the top of the script, right after the shebang, create a variable SERVER with the value web-02, and use it instead of the name in all three lines. The server name itself must appear in the script only once — where the variable is set.
Run the script (bash deploy.sh) and make sure all three lines now say web-02.
- bash scripts
- variables
- variable expansion
- quotes