1[root@Gin scripts]#cattab.txt2ww CC IDD3[root@Gin scripts]#awk'BEGIN{FS="\t+"}{print $1,$2,$3}'tab.txt4ww CC IDD 1[root@alwen opt]#catmy.txt2root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologin3alwen:x:0:0:alwen:/home/alwen:/bin/bash4lamp:x:1000...
split( String, A, [Ere] ) 将String 参数指定的参数分割为数组元素 A[1], A[2], . . ., A[n],并返回 n 变量的值。此分隔可以通过 Ere 参数指定的扩展正则表达式进行,或用当前字段分隔符(FS 特殊变量)来进行(如果没有给出 Ere 参数)。除非上下文指明特定的元素还应具有一个数字值,否则 A 数组中...
split() 字符串分割 systime() Unix 时间戳 strftime() 时间格式化,用法同C语言中的strftime 函数 rand() 随机数 sin() 正弦 cos() 余弦 sqrt() 平方根 exp() 求幂 4,awk 运算符 awk 支持如下常用运算符: 运算符含义 + - * / & 加,减,乘,除,求余 = += -= *= /= %= ^= **= 赋值运算符...
复制 awk'BEGIN{printf "%-15s %-15s %-15s\n","User","Home","Size(MB)"}{split($2,path,"/");size=sprintf("%.2f",$3/1024/1024);printf "%-15s %-15s %-15s\n", path[3],path[2]"/"path[3],size}'<(du-sb/home/*) 附:awk脚本示例 将以下脚本保存为nginx_monitor.awk: 代码...
split(str,array,fs) 按fs 切割字符串,结果保存 array 切割后的子串的个数 match(str,RE) 在str 中按照 RE 查找,返回位置 返回索引位置 sub(RE,RepStr,str) 在str 中搜索符合 RE 的字串,将其替换为 RepStr;(只替换第一个) 替换的个数 gsub(RE,RepStr,str) 在str 中搜索符合 RE 的字串,将其替换为...
linux 文本分析工具---awk命令(7/1),awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大。简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部分再进行各种分析处理。awk有3个不同版本:awk、n
awk 'BEGIN{info="this is a test";split(info,tA," ");print length(tA);for(k in tA){print k,tA[k];}}' 4 4 test 1 this 2 is 3 a #分割 info,动态创建数组 tA,awk for …in 循环,是一个无序的循环。 并不是从数组下标
split(s, a [, r]) Splits the string s into the array a on the regular expression r, and returns the number of fields. If r is omitted, FS is used instead. The array a is cleared first. Splitting behaves identically to field splitting, ...
awk'BEGIN{info="this is a test";split(info,tA," ");print length(tA);for(k in tA){print k,tA[k];}}'4 4test1 this 2 is 3 a #分割 info,动态创建数组 tA,awk for …in 循环,是一个无序的循环。 并不是从数组下标 1…n 开始...
Functions that process strings now count Unicode code points, not bytes; this affects length, substr, index, match, split, sub, gsub, and others. Note that code points are not necessarily characters. UTF-8 sequences may appear in literal strings and regular expressions. Arbitrary characters may...