command
meaning
$@ $*
represent all arguments
$#the number of arguments
$0the script name
$1the first argument name
$the ten argument name
basename: get the file name except dir path
dirname: get dir path except file name
#! /bin/bash
#./arglist.sh abc def ghi jkl mno pqr stu
echo "there are $@"
echo "there are $*"
echo "there are $#"
echo "there are $1"
echo "there are $"
##########result
#there are abc def ghi jkl mno pqr stu
#there are abc def ghi jkl mno pqr stu
#there are 7
#there are abc
#there are
##########key point
##########1."$@" and "$*" represent all arguments
##########2."$#" indicates the number of arguments
##########3."$0" represents the name of the script
##########4."$1" represents the name of the first argument
##########5."$" represents the name of the ten argument
#########get script file name and dir path
echo "the script file name `basename $0`"
echo "the script file name"
echo `basename $0`
echo "the script file dir path `dirname $0`"
echo "the script file dir path"
echo `dirname $0`
#########result
#the script file name arglist.sh
#the script file name
#arglist.sh
#the script file dir path .
#the script file dir path
#.
再談引數列表
我記得上次寫了一篇文章,說用引數傳遞的方式來縮小類中的成員變數的作用範圍。實踐證明,這種做法是正確的,只是有的時候,過長的引數列表讓 看起來不舒服 不是有編碼規範嗎,規定引數列表中的引數不能超過5個 但是對於降低 的bug產出率來說,這點不舒服是必須忍受的,有什麼便宜都佔盡的道理呀 又囉嗦了 今天我...
可變引數列表
模擬實現printf函式 va list是在c語言中解決變參問題的一組巨集,所在標頭檔案 include 用於獲取不確定個數的引數 va start,函式名稱,讀取可變引數的過程其實就是在堆疊中,使用指標,遍歷堆疊段中的引數列表,從低位址到高位址乙個乙個地把引數內容讀出來的過程 va arg,這個巨...
可變引數列表
小二,上 class a public class varargs two param static void twostringparam string a,string b three param 參照上兩種寫法,一直往後面加。是不是感覺很憂傷 幸好這不是真的。string.a static v...