回答編集履歴
4
変更
test
CHANGED
@@ -1,16 +1,6 @@
|
|
1
1
|
iptableへの設定ファイルの作成と考えて作成してみました(-sはIP指定としています)
|
2
2
|
|
3
|
-
```bash
|
4
|
-
|
5
|
-
awk '!/-A INPUT -s/{
|
6
|
-
|
7
|
-
if($3=="-m"){while((getline v<"ipfile.txt")>0){printf"-A INPUT -s %s -j ACCEPT\n",v}}
|
8
|
-
|
9
|
-
print}' file.txt
|
10
|
-
|
11
|
-
```
|
12
|
-
|
13
|
-
-s、-m
|
3
|
+
-s、-mで判定する場合
|
14
4
|
|
15
5
|
|
16
6
|
|
3
変更
test
CHANGED
@@ -16,9 +16,9 @@
|
|
16
16
|
|
17
17
|
```bash
|
18
18
|
|
19
|
-
awk '$
|
19
|
+
awk '$1!="-A" || $2!="INPUT" || $3!="-s"{
|
20
20
|
|
21
|
-
if($3=="-m"){while((getline v<"ipfile.txt")>0){printf"-A INPUT -s %s -j ACCEPT\n",v}}
|
21
|
+
if($1=="-A" && $2=="INPUT" && $3=="-m"){while((getline v<"ipfile.txt")>0){printf"-A INPUT -s %s -j ACCEPT\n",v}}
|
22
22
|
|
23
23
|
print}' file.txt
|
24
24
|
|
2
変更
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
awk '!/-A INPUT -s/{
|
6
6
|
|
7
|
-
if($3=="-m"){while((getline v<"ipfile.txt")>0){print"-A INPUT -s %s -j ACCEPT",v}}
|
7
|
+
if($3=="-m"){while((getline v<"ipfile.txt")>0){printf"-A INPUT -s %s -j ACCEPT\n",v}}
|
8
8
|
|
9
9
|
print}' file.txt
|
10
10
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
awk '$3 != "-s"{
|
20
20
|
|
21
|
-
if($3=="-m"){while((getline v<"ipfile.txt")>0){print"-A INPUT -s %s -j ACCEPT",v}}
|
21
|
+
if($3=="-m"){while((getline v<"ipfile.txt")>0){printf"-A INPUT -s %s -j ACCEPT\n",v}}
|
22
22
|
|
23
23
|
print}' file.txt
|
24
24
|
|
1
追加
test
CHANGED
@@ -10,4 +10,16 @@
|
|
10
10
|
|
11
11
|
```
|
12
12
|
|
13
|
-
-mのみの判定で良い
|
13
|
+
-s、-mのみの判定で良い場合
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```bash
|
18
|
+
|
19
|
+
awk '$3 != "-s"{
|
20
|
+
|
21
|
+
if($3=="-m"){while((getline v<"ipfile.txt")>0){print"-A INPUT -s %s -j ACCEPT",v}}
|
22
|
+
|
23
|
+
print}' file.txt
|
24
|
+
|
25
|
+
```
|