The Shell is process-oriented
(Bash for example)
Variables are process variables, process ends, and variables disappear.
Bash Variable type:
Environment variables
Local variables (local variables):
Positional variables
Special variables
Local variables: Set Varname=value
scope for the entire bash process
Local variables:
local Varname=value scope is the current code snippet
environment variable: scope is the current shell process and its child processes
Export varname=VALUE
Or
Varname=value
Export VARNAME
Positional variables:
$
Special variables:
$? Save last command execution status return value
program execution, there may be two kinds of return values:
Status Return code: (0~255)
0: Correct execution
1-255: Various error executions, 1, 2, 127 system reserved
echo $? Look at the results
-------------------------------------------
/dev/null: Software devices, data black holes
-------------------------------------------
Undo Variable
Unset VARNAME
(The $VARNAME represents the action value, not the $ representation of the action variable)
View variables for the current shell
Set (including environment variables and local variables)
To view environment variables in the current shell:
Printenv
Env
Export
modifying variables
Ga=aaa
Modified: ga= $GA: Aa:ss separated by colons
Variable does not do arithmetic arithmetic (default is string save)
A=3
B=3
c= $A + $B
echo $C//3+3
Linux is just a no elf executable file
Script file First line
Shebang: Magic number (according to this selection shell execution)
#! /bin/bash
If the script cannot execute:
1. Permissions
2. Environment variable (can write absolute path if no environment variable is added)
3. Or use the Interpreter directly (bash) to execute bash f.sh, if you want it to execute independently, you must have execute permissions.
This article from the "90 Design Studio" blog, reproduced please contact the author!
Shell and bash variable types