Rev | Line | |
---|
[185] | 1 | #!/bin/bash |
---|
| 2 | # Program: |
---|
[187] | 3 | # Delete duplicating VM MAC |
---|
[185] | 4 | # Author: |
---|
| 5 | # Rock {waue, shunfa, rock}@nchc.org.tw |
---|
| 6 | # Version: |
---|
| 7 | # 1.0 |
---|
| 8 | # History: |
---|
| 9 | # 2010/08/26 Rock First release (1.0) |
---|
| 10 | |
---|
| 11 | # 刪掉空白行 |
---|
| 12 | #sed -i '/^$/d' "$1" |
---|
| 13 | |
---|
| 14 | #read -p "cp - f $1 ${1}.old ; $?" |
---|
| 15 | cp $1 $1.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak |
---|
| 16 | |
---|
[187] | 17 | # Delete duplating VM MAC |
---|
| 18 | for vm_mac in $(echo $VM_MACs) |
---|
[185] | 19 | do |
---|
[187] | 20 | vm_mac_lines=$(cat -n $1 | grep $vm_mac | awk '{print $1}' ) |
---|
[185] | 21 | # no duplicated vlaue, doesn't do it |
---|
[187] | 22 | if [ -n $vm_mac_lines ]; then |
---|
| 23 | vm_mac_count=$(echo $vm_mac_lines | wc -w) |
---|
[185] | 24 | |
---|
[187] | 25 | for (( i=1; i<=${VM_mac_count}; i++ )) |
---|
[185] | 26 | do |
---|
[187] | 27 | del_line=$(echo $vm_mac_lines | cut -d " " -f${i}) |
---|
[185] | 28 | sed -i "${del_line}d" $1 |
---|
| 29 | done |
---|
| 30 | fi |
---|
| 31 | done |
---|
| 32 | |
---|
| 33 | |
---|
Note: See
TracBrowser
for help on using the repository browser.