Skip to main content
InterviewHubPRO
Section Overview
Q20

Question 20 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

40%
Bash & Shell Scripting (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What is the difference between `source ./script.sh` (or `. ./script.sh`) and `./script.sh`?

senior LevelSystem Design

In Simple Words:

  • ./script.sh: Launches a new separate child Bash process. Environment variables modified inside the script die when the child process exits.
  • source ./script.sh (or . script.sh): Executes the script inside the current calling shell process. Any exported variables, aliases, or functions defined in the script remain active in the current shell.