Usage and Best Practices of Linux Shebang (#!)

In many script files, we can see the following code on the <span>first line</span>: #!/bin/bash 或 #!/usr/bin/env python Carefully observe that the first line of the script file starts with the characters <span>#!</span>. This character sequence consisting of <span>hash</span> and <span>exclamation mark</span> is called <span>Shebang</span> (also known as <span>Hashbang</span>). Its purpose is to tell the … Read more

Linux(18): Creating Bash Scripts

Linux(18): Creating Bash Scripts

1. Core Purpose & Concepts Core Purpose: To write a series of Linux commands that need to be executed in order into a text file, creating a “script”. By running this single script file, a multi-step task can be automated without manually entering each command. Core Terminology: Bash Script: A plain text file containing a … Read more

Differences Between source xxx.sh and ./xxx.sh in Linux

Differences Between source xxx.sh and ./xxx.sh in Linux

Both source xxx.sh and ./xxx.sh are common methods for executing Shell scripts in Linux/Unix systems, and they have fundamental differences in execution environment, permission requirements, and their impact on the current Shell. The table below summarizes their core differences for easier understanding: Feature Comparison <span>source xxx.sh</span> <span>./xxx.sh</span> Execution Environment Current Shell Process New Sub Shell … Read more