2013年1月16日 星期三

[Bash][function] Passing parameters to a bash function


#!/bin/sh
foo 1  # this will fail because foo has not been declared yet.

foo() {
    echo "Parameter #1 is $1"
}

foo 2 # this will work.

Output :
happy@happy-laptop:~/Desktop/test2$ sh test3.sh
test3.sh: 3: foo: not found
Parameter #1 is 2

Reference :

Related Posts:

0 意見:

張貼留言