Mastering User-Defined Functions and Alternative Shells in Linux
1. User-Defined Functions in gawk
In gawk, you’re not restricted to using only the built - in functions. You can create your own functions for use in gawk programs.
1.1 Defining a Function
To define your own function, you must use the function keyword:
function name([variables])
{
statements
}
The function name should uniquely identify your function. You can pass one or more variables into the function from the calling gawk program. For example:
function printthird()
{
print $3
}
This function prints the third data field in the record.
A function can also return a value using
超级会员免费看
订阅专栏 解锁全文
2346

被折叠的 条评论
为什么被折叠?



