aboutsummaryrefslogtreecommitdiffstats
path: root/ft-combine-samples
blob: a1f19ed3ae57cbf7488c80881a90bc70762ea938 (plain) (blame)
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
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash

STRIP_CMD=""

function add_strip()
{
    TAG=$1
    STRIP_CMD="$STRIP_CMD -e s/_${TAG}=[^_]*//"
}

while true
do
    case "$1" in
	-n | --task-count)
	    shift
	    add_strip n
	    ;;

	-c | --cpu)
	    shift
	    add_strip cpu
	    ;;

	-m | --msg)
	    shift
	    add_strip msg
	    ;;

	-s | --seq)
	    shift
	    add_strip seq
	    ;;

	-u | --util)
	    shift
	    add_strip u
	    ;;

	-l | --locks)
	    shift
	    add_strip locks
	    ;;

	-x | --custom)
	    shift
	    add_strip $1
	    shift
	    ;;

	--std)
	    shift
	    add_strip n
	    add_strip cpu
	    add_strip msg
	    add_strip seq
	    add_strip u
	    ;;

      *)
	  break
	  ;;
    esac
done

if [ -z "$STRIP_CMD" ]
then
    echo "Error: no fields to strip specified."
    exit 1
fi

function do_append() {
    TARGET=`basename $1 | sed $STRIP_CMD`
    TARGET="combined-$TARGET"
    printf "\n[$NUM/$TOTAL] Combining $1 -> $TARGET\n"
    cat $1 >> $TARGET
}

TOTAL=$#
NUM=0

echo "File names will be mangled with: sed $STRIP_CMD"


while [ "" != "$*" ]
do
    NUM=$((NUM + 1))
    do_append "$1"
    shift
done