课程: AWK Essential Training

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Creating user-defined variables

Creating user-defined variables - Linux教程

课程: AWK Essential Training

Creating user-defined variables

- [Instructor] Now since AWK is a programming language, if you know anything about programming languages you would expect it to have user defined variables as well as the built in ones. And indeed it does. A variable is just a name that holds a value. Variable names consist of letters, digits, and underscores and may not begin with a digit. You don't need to declare or define a variable in AWK. Variables are created as soon as you use them. This is convenient, but it also means that if you make a mistake when typing a variable name it silently creates a new variable with the mistaken name instead of causing an error. For example, we write a program, hello, equal dollar one goodbye equal dollar two, and then we'll print. So in this case, we type two fields of input and it only prints the second one. The first field of the input was assigned to the variable 'hello' but when it went to print it because it had the typo 'ehllo'…

内容