-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummaryparse
executable file
·53 lines (43 loc) · 912 Bytes
/
summaryparse
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
#!/bin/bash
GREPS=("$@")
COLS=${#GREPS[@]}
# Get directories
DATA=()
TEMPARRAY=(`ls */summary|xargs|sed 's/\/summary//g'`)
DATA=( ${TEMPARRAY[@]} )
# Get grepped values
for GREP in ${GREPS[@]};
do
TEMPARRAY=(`grep $GREP */summary|awk '{print $2}'|xargs`)
DATA=( ${DATA[@]} ${TEMPARRAY[@]} )
done
#
#Compile into tex-style table
#
#Get number of rows
ROWS=$((${#DATA[@]}/$((COLS+1))))
format="%-40s"
for i in `seq 0 $((COLS-1))`
do
format="$format & %6s"
done
format="$format \\\\\\\\\n"
values=("directory" ${GREPS[@]})
#echo $format
#echo ${values[@]}
#c=0
#for i in ${DATA[@]}
# do echo $c $i;c=$((c+1));done;
printf "$format" ${values[@]}
for i in `seq 0 $((ROWS-1))`
do
values=(${DATA[i]})
for j in `seq 1 $COLS`
do
ind=$((ROWS*j+i))
#echo $ind: ${DATA[$ind]}
values="$values ${DATA[$ind]}"
done
#echo ${values[@]}
printf "$format" ${values[@]}
done