Last change
on this file since 214 was
174,
checked in by rock, 14 years ago
|
新增功能 1.叢集狀態檢視 2.增加註解文字
|
-
Property svn:executable set to
*
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | # Program: |
---|
3 | # Delete duplicating ip $ hostname in file (for nutchez management interface). |
---|
4 | # Author: |
---|
5 | # Waue, Shunfa, Rock {waue, shunfa, rock}@nchc.org.tw |
---|
6 | # Version: |
---|
7 | # 1.0 |
---|
8 | # History: |
---|
9 | # 2010/06/07 Rock First release (1.0) |
---|
10 | |
---|
11 | # Delete duplicating ip addresss in file |
---|
12 | IPs=$(cat $1 | grep -v 'ip6' | grep -v '#' | grep -v '^$' | awk '{print $1}') |
---|
13 | |
---|
14 | # 刪掉空白行 |
---|
15 | #sed -i '/^$/d' "$1" |
---|
16 | |
---|
17 | cp -f "$1" "${1}.old" |
---|
18 | #read -p "cp - f $1 ${1}.old ; $?" |
---|
19 | |
---|
20 | for ip_add in $(echo $IPs) |
---|
21 | do |
---|
22 | ip_nu=$(cat -n $1 | grep $ip_add | awk '{print $1}') |
---|
23 | ip_count=$(echo $ip_nu | wc -w) |
---|
24 | |
---|
25 | for (( i=1; i<${ip_count}; i++ )) |
---|
26 | do |
---|
27 | del_line=$(echo $ip_nu | cut -d " " -f${i}) |
---|
28 | sed -i "${del_line}d" $1 |
---|
29 | done |
---|
30 | done |
---|
31 | |
---|
32 | # Dlete duplicating hostname in file |
---|
33 | hostnames=$(cat $1 | grep -v ip6 | grep -v '#' | grep -v '^$' |awk '{print $2}') |
---|
34 | for host in $(echo $hostnames) |
---|
35 | do |
---|
36 | # line numbers |
---|
37 | host_nu=$(cat -n $1 | grep "$host\$" | awk '{print $1}') |
---|
38 | host_count=$(echo $host_nu | wc -w) |
---|
39 | |
---|
40 | for (( i=1; i<${host_count}; i++ )) |
---|
41 | do |
---|
42 | del_line=$(echo $host_nu | cut -d " " -f${i}) |
---|
43 | sed -i "${del_line}d" $1 |
---|
44 | done |
---|
45 | done |
---|
46 | |
---|
47 | cp -f "$1" "${1}.bak" |
---|
48 | #read -p "cp -f $1 ${1}.bak ; $?" |
---|
Note: See
TracBrowser
for help on using the repository browser.