-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4lines.bash
More file actions
48 lines (42 loc) · 956 Bytes
/
4lines.bash
File metadata and controls
48 lines (42 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# test edition
# author : Francois Gardavaud
# version date : 16-05-2019
# purpose : script to avoid dupplicate transfert on the same distant host
# in my case eliminate the following block in .proto files
# the structure is in my case :
# AutoXferHostInfo {
# autoXferHostName = "AWS"
# autoXferMode = 1
# }
# /!\/!\/!\/!\ the deletion is only effective if and only if the previous lines are consecutive /!\/!\/!\/!\
linesref=(' AutoXferHostInfo {' \
' autoXferHostName = "AWS"' \
' autoXferMode = 1' \
' }' \
)
n=${#linesref[*]}
declare -a lines
i=0
while IFS= read lines[$i] ; do
let i++
if [ $i -eq $n ] ; then
block=true
for (( j=0; j < $n; j++ )); do
[ "${lines[$j]}" != "${linesref[$j]}" ] && block=false
done
if [ $block == true ] ; then
let i=0
else
echo "${lines[0]}"
for (( j=1; j < $n; j++ )); do
let k=$j-1
lines[$k]=${lines[$j]}
done
let i--
fi
fi
done
for (( j=0; j < $i; j++ )) ; do
echo "${lines[$j]}"
done