Functions的知识要点
时间:2006-08-25 来源:sosogh
Functions的知识要点
1。当你定义了Functions后,它已经存在内存里面, 所以当你调用它的时候,它会运 行的快点
2.函数有2种定义方式,在功能上没有什么差别
(1)
function functname{ shell commands}
(2)
functname ( ) { shell commands } 3.如果想取消一个函数使用以下命令:unset -f functname
4.使用函数
If you want to run the function later, just type in its name followed by any arguments, as if it were a shell script
5.查看已经定义过的函数
You can find out what functions are defined in your login session by typing declare -f. The shell will print not just the names but the definitions of all functions, in alphabetical order by function name. Since this may result in long output, you might want to pipe the output through more or redirect it to a file for examination with a text editor. If you just want to see the names of the functions, you can use declare -F.[1] We will look at declare in more detail in Chapter 6. [1] The -F option is not available in versions of bash prior to 2.0.
1。当你定义了Functions后,它已经存在内存里面, 所以当你调用它的时候,它会运 行的快点
2.函数有2种定义方式,在功能上没有什么差别
(1)
function functname{ shell commands}
(2)
functname ( ) { shell commands } 3.如果想取消一个函数使用以下命令:unset -f functname
4.使用函数
If you want to run the function later, just type in its name followed by any arguments, as if it were a shell script
5.查看已经定义过的函数
You can find out what functions are defined in your login session by typing declare -f. The shell will print not just the names but the definitions of all functions, in alphabetical order by function name. Since this may result in long output, you might want to pipe the output through more or redirect it to a file for examination with a text editor. If you just want to see the names of the functions, you can use declare -F.[1] We will look at declare in more detail in Chapter 6. [1] The -F option is not available in versions of bash prior to 2.0.
相关阅读 更多 +