-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetDataFromReplicatedVector.sh
More file actions
executable file
·34 lines (26 loc) · 1.26 KB
/
getDataFromReplicatedVector.sh
File metadata and controls
executable file
·34 lines (26 loc) · 1.26 KB
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
#!/bin/bash
VECTOR_DIRNAME="$1"
if [ -d "$VECTOR_DIRNAME" ]
then
find "$VECTOR_DIRNAME"/*.vec | while read file
do
# remove the vector name (directory)
VECT_FILE=`echo "$file" | cut -d\/ -f 2`
export VECTOR_FILE_ID=`echo "$VECT_FILE" | cut -d. -f 1 | awk -F- '{ print $(NF) }'`
export REPLICA_ID=`echo "$VECT_FILE" | cut -d. -f 1 | awk -F- '{print $(NF-1) }'`
export EXPERIMENT=`echo "$VECT_FILE" | cut -d. -f 1 | awk -v Repl=$REPLICA_ID -v Vect=$VECTOR_FILE_ID '{ sub("-"Repl"-"Vect,"",$0);print }'`
export MODULE=`head -n 1 "$file" | cut -d' ' -f 4`
export VECTOR_NAME=`head -n 1 "$file" | awk -v l1=$MODULE '{ v=index($0,l1)+length(l1)+1; e=length($0)-v+1; print substr($0,v,e)}'`
VECTOR_NAME=`echo $VECTOR_NAME | awk '{ gsub("\"","",$0); print }'`
echo "procesing $file, Module: $MODULE VectorName: $VECTOR_NAME Experiment $EXPERIMENT"
OUTPUT_FILE="$VECTOR_NAME-$MODULE.data"
if [ ! -f "$OUTPUT_FILE" ]
then
echo "Experiment Replica Time Obs" > "$OUTPUT_FILE"
fi
tail -n +5 "$file" | gawk -F, '{print ENVIRON["EXPERIMENT"],ENVIRON["REPLICA_ID"],$1,$2}' >> "$OUTPUT_FILE"
done
else
echo "usage: $0 {vector_name}"
echo "Vector name must be a directory containing one single vector file for each replica"
fi