From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Sourcing and aliasing with Bash

Sourcing and aliasing with Bash

- [Narrator] Sourcing is an important feature of shells and it's used a moderate amount. So you well may see it and you might want to do it. When you source a script, what you're doing is telling your current shell to execute the commands within the shell. For example, if there's variable assignments in the sourced script, then your shell will have those variables assigned. There's two ways of sourcing. There's the source command, which I prefer that. Or you could just say dot space, name of the script to source it. That's shorter and some folks like to see that. And that can be pretty confusing. If you're trying to read someone else's script and you see dot space, hey, they're sourcing the other script. Look in that script to see what variables and/or functions they're defining. That's why you do it. So you're using sourcing to import variable assignments and functions, and by definition, sourcing has side effects on your shell. It's changing your shell. So of course you got to be…

Contents