All System Variables
env |
User Defined Variables
# 等號兩邊不能直接接空白字元 |
指令
version=$(uname -r) |
Built-in shell variables
Variable Use
$? the exit value of the last command that was executed.
$# the number of command-line arguments that were passed to the shell program.
$* all the arguments that were entered on the command line ($1 $2 ...).
$@ all the arguments that were entered on the command line, individually quoted ("$1" "$2" ...).
$0 the first word of the entered command (the name of the shell program).
e.g.
./command -yes -no /home/username
- $# = 3
- $* = -yes -no /home/username
- $@ = array: {“-yes”, “-no”, “/home/username”}
- $0 = ./command
- $1 = -yes
Delete
#
基本的用法
$(variable#string) |
variable
是變數名string
是欲刪除的字串,可以搭配萬用字元?
*
使用
實際的作用是:由左至右,刪除符合字串中最短的那一個(因為有萬用字元)
舉例:
SOME_FILE=some_file.png |
%
則是相反
舉例:
PNG_FILE=somefile.png |