Linux CLI 54 ๐ง shell script variables
a - variables
variables are used to store and manipulate data
Declaring variables โ by assigning a value to them using =
There should be no spaces around =
my_variable="Hello, World!" โ declares a variable
Accessing variables โ using $ with the variable name you can access its value
echo $my_variable โ prints the data stored in the variable
You can use variables in shell scripts and in the Command line.
You can unset a variable using unset
b - special variables
Shell scripts have several special variables that are automatically set by the shell
$0 โ The name of the script.
$1 to $9 โ Positional parameters passed to the script.
$# โ Number of positional parameters.
$* โ All the positional parameters as a single word.
$@ โ All the positional parameters as separate words.
$$ โ Process ID of the current script.
$? โ Exit status of the last command executed.
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!