$0,$1,$2 and set - in shell ,awk ,sed,function ,perl

来源:互联网 发布:淘宝网宋大师旗舰店 编辑:程序博客网 时间:2024/04/29 10:47

set – a b c  …

tells ksh to assign $1 = a,  $2 = b, $3 = c … as if the script had been called:  script a b c …
Then the script can use normal command line parsing tools like getopts.

IFS is the input field separator.  By default this is set to white space (space, tab, or newline).  By adding ‘%’, ksh will replace % with a space when a variable is echoed.

set –A arrayName a b c … creates an array and assigns members arrayName[0]=a, arrayName[1]=b, arrayName[2]=c…


specail  symbol :

it  represent parameter all , parameter 1,2,3 ....for shell ,awk ,function

for awk, $1 $2 , are also  used in  -F

 

for regular match

sed use \1

perl usr $(1)


原创粉丝点击