Get the latest news about the world's Open Source Leader
Red Hat Network
Manage your system dffectively through Red Hat Network
Global Learning Services
You've got Red Hat Enterprise Linux,now get the skills
check out Red Hat's training courses and industry-acclaimed
2009082301
#This is a test456 line
space test123 line234
[root@Siegfried test]# awk '{print}' a
[root@Siegfried test]# awk 'NR==8{print}' a
[root@Siegfried test]# awk -F\ '{print $1}' a
[root@Siegfried test]# awk 'END{print NR}' a
[root@Siegfried test]# awk -F\ '{print NF}' a
[root@Siegfried test]# awk 'END{print $NF}' a
[root@Siegfried test]# awk '{if(NF>4) print NR}' a
[root@Siegfried test]# awk -F\ 'BEGIN{num=0; sum=0}{num=NF; sum=sum+num}END{print sum}' a
[root@Siegfried test]# awk -F: '{if($3>=30&&$3<=40)print $1}' /etc/passwd
#!/bin/awk -f
BEGIN{
FS=" "
}
printf("%s%s",$i,FS)
printf("\n")
}
11.打印3-8行
[root@Siegfried test]# awk '{if(NR>=3&&NR<=8)print}' a
[root@Siegfried test]# awk 'BEGIN{print "Document"}{print}' a
[root@Siegfried test]# awk '{if(NR%2==0) print}' a
[root@Siegfried test]# awk '{if(NR%2==1) print}' a
#!/bin/awk -f
BEGIN{
FS=" "
print $1
#!/bin/awk -f
BEGIN{
FS=" "
print ($1" "$3)
16.打印字段数大于5个的行总数
[root@Siegfried test]# awk -F\ 'BEGIN{num=0}{if(NF>5)num++}END{print num}' a