摘要: 4、Generic String FunctionsIndex FunctionThe index function can be used to get the index (location) of thegiven string (or character) in an input string.You can also use index to check whether a given string (or character)is present in an input string. If the given string is not present, it willretur 阅读全文
posted @ 2013-09-06 15:56 风*依旧 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 1、Pretty Printing Using printfSyntax:printf "print format", variable1, variable2, etc.Special Characters in the printf FormatThe following prints "Line 1" and "Line 2" in separate lines using newline:$ awk 'BEGIN { printf "Line 1\nLine 2\n" }'Line 1Lin 阅读全文
posted @ 2013-07-16 21:35 风*依旧 阅读(663) 评论(0) 推荐(0) 编辑
摘要: 1、Assigning Array ElementsIn Awk, arrays are associative, i.e. an array contains multiple index/value pairs. The index doesn't need to be a continuous set of numbers; in fact it can be a string or a number, and you don't need to specify the size of the array.Syntax:arrayname[string]=valuearr 阅读全文
posted @ 2013-07-10 21:28 风*依旧 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 1、Simple If Statement语法:if (conditional-expression)action如果是多个action,则语法如下:if (conditional-expression){action1;action2;}Print all the items with quantity <=5:$ awk -F "," '{ if ($5 <= 5) \print "Only",$5,"qty of",$2, "is available"; }' \items.txt 阅读全文
posted @ 2013-06-28 18:53 风*依旧 阅读(399) 评论(0) 推荐(0) 编辑
摘要: 1、VariablesYou don't need to declare anvariable to use it. If you wish to initialize an awk variable, it is betterto do it in the BEGIN section, which will be executed only once.There are no data types in Awk. Whether an awk variable is a numberor a string depends on the context in which the var 阅读全文
posted @ 2013-06-19 18:42 风*依旧 阅读(451) 评论(0) 推荐(0) 编辑
摘要: 1、FS - Input Field Separatorawk处理文档时,默认的域分隔符为空格,所以如果你的输入文件的域分隔符不是空格,可以通过-F选项来指定分隔符,如下所示:awk -F ',' '{print $2, $3}' employee.txt我们也可以使用awk内置变量FS来设置分隔符,需要在BEGIN块里设置:awk 'BEGIN {FS=","} {print $2, $3}' employee.txt我们还可以指定多个域分隔符,例如存在以下记录文件,其中的每条记录包含3个不同的域分隔符:逗号、冒号和百分号: 阅读全文
posted @ 2013-06-07 16:34 风*依旧 阅读(530) 评论(0) 推荐(0) 编辑
摘要: awk是一个操作处理文本文件的强大工具,尤其是处理记录型的文本,也就是每行文本包含多个用分隔符分隔的域。甚至在没有输入文本的情况下也可以做一些逻辑处理。在接下来的示例中,我们会多次用以下的文档作为操作的对象:employee.txt is a comma delimited file that contains 5 employeerecords in the following format:employee-number,employee-name,employee-titleCreate the file:$ vi employee.txt101,John Doe,CEO102,Jaso 阅读全文
posted @ 2013-06-05 11:31 风*依旧 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 1、追加下一行文本到Pattern Space中(N command)正如大写的H和G命令是追加而非替代,大写的N命令也是把下一行文本追加到Pattern Space中,而非替换原Pattern Space中的内容。我们先前讨论过,小写的n命令是打印当前的Pattern Space中的内容,清空Pattern Space中的内容,读取下一行内容到Pattern Space中,然后恢复它接下来的命令流程。但是大写的N命令,不会打印当前Pattern Space中的内容,也不会清除Pattern Space;它会在Pattern Space中的当前文本后添加一个新行(\n),从输入文件中读取下一行 阅读全文
posted @ 2013-04-11 16:31 风*依旧 阅读(589) 评论(0) 推荐(0) 编辑
摘要: 深入理解Java内存模型(一)——基础深入理解Java内存模型(二)——重排序深入理解Java内存模型(三)——顺序一致性深入理解Java内存模型(四)——volatile深入理解Java内存模型(五)——锁深入理解Java内存模型(六)——final深入理解Java内存模型(七)——总结 阅读全文
posted @ 2013-04-09 19:58 风*依旧 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 聊聊并发(一)——深入分析Volatile的实现原理聊聊并发(二)——Java SE1.6中的Synchronized聊聊并发(三)——JAVA线程池的分析和使用聊聊并发(四)——深入分析ConcurrentHashMap聊聊并发(五)——原子操作的实现原理聊聊并发(六)——ConcurrentLinkedQueue的实现原理分析 阅读全文
posted @ 2013-04-09 19:54 风*依旧 阅读(146) 评论(0) 推荐(0) 编辑