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 - Linux Tutorial
From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Exploring the Bash documentation2m 27s
-
(Locked)
Setting the script interpreter and permissions5m 49s
-
(Locked)
Date and time commands5m 36s
-
(Locked)
Shell variables4m 28s
-
(Locked)
Bash startup2m 52s
-
(Locked)
Sourcing and aliasing with Bash3m 31s
-
(Locked)
Displaying text with the echo command4m 12s
-
(Locked)
Challenge: Exported variables, sourcing, and echo2m 17s
-
(Locked)
Solution: Exported variables, sourcing, and echo4m 7s
-
-
-
-
-