Chinaunix首页 | 论坛 | 博客
  • 博客访问: 514113
  • 博文数量: 238
  • 博客积分: 10208
  • 博客等级: 上将
  • 技术积分: 2820
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-12 09:27
文章分类

全部博文(238)

文章存档

2010年(50)

2009年(66)

2008年(122)

我的朋友

分类: LINUX

2008-12-06 19:47:59

1. Awk is not very particular about the placement of braces and statements (unlike sed).The opening brace is placed after the conditional expression, either on the same line or on the next line. The first statement can follow the opening brace or be placed on the line following it. The closing brace is put after the last statement, either on the same line or after it. Spaces or tabs are allowed before or after the braces.(sed and awk chapter 8)
2.POSIX added a new variable, CONVFMT, which is used to control number-to-string conversions. For example,
str = (5.5 + 3.2) " is a nice value"

Here, the result of the numeric expression 5.5 + 3.2 (which is 8.7) must be converted to a string before it can be used in the string concatenation. CONVFMT controls this conversion. Its default value is "%.6g", which is a printf-style format specification for floating-point numbers. Changing CONVFMT to "%d", for instance, would cause all numbers to be converted to strings as integers. Prior to the POSIX standard, awk used OFMT for this purpose. OFMT does the same job, but controlling the conversion of numeric values when using the print statement. The POSIX committee wanted to separate the tasks of output conversion from simple string conversion. Note that numbers that are integers are always converted to strings as integers, no matter what the values of CONVFMT and OFMT may be.


阅读(544) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~