我的文件是这样的:
Internet 10.1.1.2 76 ACCEPT
Internet internal1 1140 ACCEPT
internal1 10.24.13.166 275074 ACCEPT
Internet 10.24.13.166 152 ACCEPT
我想在前两个IP上做AWK来识别它们是互联网,内部1还是其他。在这种情况下,我想得到这个结果:
10.25
因此,如果这是10.
,则为internal1。否则,如果这是cat x | awk -F. '{if($1 == 10 && $2 == 25) { print "internal1 " } else if($1 == 10) { print $0 } else {print "Internet "}
,这是“其余的”,如果这是其他的 - 这是互联网
在第一个IP上没有问题:
Internet
Internet
internal1
Internet
然而,结果将是:
var Vue = require('vue');
var c3 = require('c3');
new Vue({
template: '<div id="puppa"></div>',
mounted: function () {
c3.generate({
bindto: '#puppa',
data: {
type: 'area',
x: 'x',
xFormat: '%H:%M',
columns:[
['x',"12:38","12:38","12:38","12:38","12:39","12:39","12:39","12:39","12:40","12:40","12:40","12:41","12:41","12:41","12:41","12:42","12:42","12:42","12:42","12:43","12:43","12:43","12:43","12:44","12:44"],
['write', 14709198848,14709313536,14709522432,14709633024,14710034432,14710157312,14710341632,14710583296,14710788096,14710931456,14711058432,14711291904,14711508992,14711668736,14711771136,14712008704,14712107008,14712381440,14712586240,14712795136,14712963072,14713077760,14713331712,14713565184,14713729024],
['read', 3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080,3778094080]
]
},
axis: {
x: {
type: 'timeseries',
tick: {
format: function (x) {
if (x.getDate() === 1) {
return x.toLocaleDateString();
}
}
}
}
}
});
}
});
所以缺少的是第1个)每行的其余部分和第2个)检查第二个IP
有什么想法吗?
答案 0 :(得分:1)
试试这个:
awk '{for (i=1;i<=2;i++) {
if ($i ~ /^10\.25\./) $i="internal1";
else if ($i !~ /^10\./) $i="Internal"} }1' x