Script with Other Commands
Learn how to use a Bash script with other commands.
We'll cover the following...
Integrating backup script into Bash
At the moment, we can run our backup script by its absolute or relative path. If we integrate it into Bash, we can call it by name. This is a convenient option when we use the script in pipelines or logical operators.
These are three ways to integrate a script into Bash:
-
Add the script’s path to the
PATH
variable. Edit the~/.bash_profile
file for that. -
Define the alias with an absolute path to the script. Do that in the
~/.bashrc
file. -
Copy the script to the
/usr/local/bin
directory and make it executable:sudo cp -r make-backup.sh /usr/local/bin/ sudo chmod +x /usr/local/bin/make-backup.sh
The
PATH
variable contains this path by default. If there is no such directory in your environment, create it.
If we need to remove a declared alias, we call the ...
Access this course and 1400+ top-rated courses and projects.