參數的assign方式? - Linux

By Susan
at 2013-12-14T16:27
at 2013-12-14T16:27
Table of Contents
/ 過參數 但好像沒有關於這問題
比如以下script:
swap()
{
tmp=$1
v2= $2
$1=${!v2}
$2=${!tmp}
}
a=5
b=1
swap a b
echo "after swap:a=$a, b=$b"
會出現command not found的message
function好像真的還蠻不好用的 不像一般程式語言可以改argument
有沒有大大有方式可以改argument的value而不經由修改全域變數的方式進行?
--
比如以下script:
swap()
{
tmp=$1
v2= $2
$1=${!v2}
$2=${!tmp}
}
a=5
b=1
swap a b
echo "after swap:a=$a, b=$b"
會出現command not found的message
function好像真的還蠻不好用的 不像一般程式語言可以改argument
有沒有大大有方式可以改argument的value而不經由修改全域變數的方式進行?
--
Tags:
Linux
All Comments

By Barb Cronin
at 2013-12-16T21:20
at 2013-12-16T21:20

By Frederic
at 2013-12-17T23:45
at 2013-12-17T23:45

By Freda
at 2013-12-21T12:52
at 2013-12-21T12:52

By Doris
at 2013-12-21T22:46
at 2013-12-21T22:46

By Mary
at 2013-12-26T13:44
at 2013-12-26T13:44

By Mary
at 2013-12-30T08:17
at 2013-12-30T08:17
Related Posts
SteamOS Beta Now Available For Download

By John
at 2013-12-14T10:16
at 2013-12-14T10:16
關於linux mint16雙系統安裝的問題

By Barb Cronin
at 2013-12-14T03:11
at 2013-12-14T03:11
提供對於漢語方言化介面有興趣者的支援

By Candice
at 2013-12-14T00:56
at 2013-12-14T00:56
Linux變成平臺的平臺的平臺

By Ingrid
at 2013-12-13T18:38
at 2013-12-13T18:38
變數中的變數?

By Dora
at 2013-12-13T15:41
at 2013-12-13T15:41