练习资源

转成txt格式

最大年龄
1 BEGIN{
2     FS="[()]";max=0
3 }
4 {
5     if(max<substr($4,6,2)){max=substr($4,6,2);name=substr($1,9)}
6 }
7 END{
8 print max,name
9 }

 

综合小例子
 1 #!/usr/bin/bash
 2 #awk [ -F re] [parameter...] ['prog'] [-f progfile][in_file...]
 3 # BEGIN   { x=0 }/^$/{ x=x+1 }END{ print "I found " x " blank lines. :)"}
 4 # BEGIN{max=1} {i=index($0,"aged");if(i>0){if(substr($0,i+5,2)>max){max=substr($0,i+5,2)}}} END{print max}
 5 #/-/ {d=(NF==7)?$6:$4;print d}
 6 
 7 
 8 
 9 #-F"[()]" "/-/{d=(NF==7)?$6:$4;a[d]++}END{for (i in a) {s='';for (j=1;j<=a[i];j++) s="*"s;print i,s|"sort -k2n"}}" d:/exp/name.txt
10 
11 BEGIN{FS="|"}{print $(NF-1)}

 

posted @ 2012-12-06 18:46  hhhyde  阅读(113)  评论(0编辑  收藏  举报