随记两个SHELL文本处理

1,对于AWK通配符的处理

例如文本:

AAAAAAAA(CZ航母STYLE+CZ航母STYLE+CZ航母STYLE+CZ航母STYLE);XXXX;CCCCC(F22战机+F22战机);33333(蘑菇云+蘑菇云);3300LS

对于排除括号内的截取可以使用如下AWK

awk -F '[(*)]' '{print $1,$3,$5}'

 

2,NodeJs+TR截取server-status Wait状态

//req.js

var http=require('http');

http.get("http://10.9.131.171/server-status", function(res) {
console.log("Got response: " + res.statusCode);
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
}).on('error', function(e) {
console.log("Got error: " + e.message);
});

node req.js|sed -n '18,26p'|tr -cd W|wc -c`

posted @ 2013-11-30 09:43  RichardParker  阅读(225)  评论(1编辑  收藏  举报