-
Notifications
You must be signed in to change notification settings - Fork 0
/
nrcfg
executable file
·77 lines (67 loc) · 1.04 KB
/
nrcfg
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# Copyright (C) 2013 Thomas Carette
nr ()
{
if [ ! -e $1 ]
then
echo "Missing file '$1'." > /dev/stderr
exit 1
fi
nl='
'
blstr=$( grep -n \* $1 )
echo ""
if $(grep -q "Core" $1)
then
echo "Grasp list"
if $( echo "$blstr" | grep -vq \* )
then
blstr=$( wc -l $1 | gawk '{ print $1 }' )
else
blstr=${blstr}${nl}$( wc -l $1 | gawk '{ print $1 }' )
fi
off0=5
off=0
div=3
else
off0=0
off=3
div=2
fi
numbl=$( echo "$blstr" | wc -l )
echo "${numbl} block(s)"
echo ""
eofbl[0]=${off0}
for bl in $( seq 1 ${numbl} )
do
tmp=$( echo "$blstr" | head -$bl | tail -1 )
eofbl[${bl}]=${tmp%:*}
echo "bl${bl} : $(( (${eofbl[${bl}]}-${eofbl[$(( ${bl}-1))]}-${off})/${div} ))"
done
}
############
if [ $# == 1 ]
then
####
nr $1
####
else
####
for i in "$@"
do
n=$( nr $i | grep "bl1* : " | awk '{print $3}' )
m=$( nr $i | grep "bl[2-9]* : " | awk '{print $3}' )
echo "$i: bl1: $n"
if [ "$m" != '' ]
then
k=2
for j in $m
do
echo " - bl${k}: $j"
k=$(( $k+1 ))
done
fi
done | column -t
####
fi
###########