Apr 27, 2009
grep+sed+sort
见如下代码:
grep uri:.*total.* */log/aaa.log.20090331* | sed -n ’s/^\(.*\):NOTICE.*logid:\([0-9]*\).*total:\([0-9]*\).*$/\3\t\2\t\1/p’ | sort -n
说明:
grep: 将aaa.log.20090331文件的含有total字段的行拉出来
sed: 将logid和total个数取出来,放在管道中,传给sort使用,这里要特别注意\1, \2的使用。
sort: 将sed数据结果进行排序,其中-n是按数字排序。如果加个-u选项,则加上了除重功能。
多谢
张久安
If you enjoyed this post, make sure you subscribe to my RSS feed!









2 Comments, Comment or Ping
吕成宝
我来逛逛。资料太少。
Apr 28th, 2009
zja601
以后会多地,
呵呵
May 6th, 2009
Reply to “grep+sed+sort”
You must be logged in to post a comment.