From the course: Linux: Bash Shell and Scripts

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Sourcing and aliasing with bash

Sourcing and aliasing with bash - Linux Tutorial

From the course: Linux: Bash Shell and Scripts

Start my 1-month free trial

Sourcing and aliasing with bash

- [Instructor] Another way to execute a shell script is to source it, and you can use the source command to source a script, or you can use dot space to source a script. What's different is when you source a script, your current shell just interprets the commands inside the source script as if they were done themself. In contrast to starting a new process to run the script. When a script is sourced and the script does things like assigns a value to a variable, then that's happening in the calling script itself. That's handy, for example, sourcing is used to import variable assignments or definitions of functions. So you can have a script that defines some functions, and you could just source it, and then you can call those functions from your script. Another handy thing to do with Bash is to define alternative, oftentimes shorter alternatives to commands. For example, a common alias ll is defined to be ls -l, so you can just type ll. So aliases are for commands, not for general…

Contents