blob: 3601bb55aa2549e4b7478c6f074776e187ac6a19 (
plain)
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
|
#!/bin/bash
declare -A min
declare -A max
for i in $* ; do
#fn=$(echo $i | awk -F \; '{print $1;}')
#vers=$(echo $i | awk -F \; '{print $2;}')
fn=$(echo $i | cut -d \; -f 1)
vers=$(echo $i | cut -d \; -f 2)
if [ -z "${min[$fn]}" ] ; then
min[$fn]=$vers
elif [ "${min[$fn]}" -gt $vers ] ; then
min[$fn]=$vers
fi
if [ -z "${max[$fn]}" ] ; then
max[$fn]=$vers
elif [ "${max[$fn]}" -lt $vers ] ; then
max[$fn]=$vers
fi
done
for i in "${!max[@]}" ; do
ma=${max[$i]}
mi=${min[$i]}
if [ $ma -gt $mi ] ; then
f=$mi
while [ $f -lt $ma ] ; do
rm ${i}\;$f
f=$(expr $f + 1)
done
fi
mv ${i}\;$ma $i
done
|