#!/bin/bash
cd $1
rm colloct.txt
step1() {
line_num=0
while read line; do
((line_num++))
if [[ $line == *"Run status group"* ]]; then
break
fi
done
read next_line
read next_line2
if [[ $next_line2 == *"WRITE:"* ]]; then
echo -n "read-write " >> colloct.txt
if [[ $next_line == *"Mib/s"* ]]; then
echo -n Mib/s- >> colloct.txt
elif [[ $next_line == *"Kib/s"* ]]; then
echo -n Kib/s- >> colloct.txt
else
echo -n : >> colloct.txt
fi
if [[ $next_line2 == *"Mib/s"* ]]; then
echo -n Mib/s: >> colloct.txt
elif [[ $next_line2 == *"Kib/s"* ]]; then
echo -n Kib/s: >> colloct.txt
else
echo -n : >> colloct.txt
fi
else
if [[ $next_line == *"WRITE:"* ]]; then
echo -n "write " >> colloct.txt
else
echo -n "read " >> colloct.txt
fi
if [[ $next_line == *"Mib/s"* ]]; then
echo -n Mib/s: >> colloct.txt
elif [[ $next_line == *"Kib/s"* ]]; then
echo -n Kib/s: >> colloct.txt
else
echo -n : >> colloct.txt
fi
fi
echo >> colloct.txt
}
step2() {
first=0
while read line; do
((line_num++))
if [[ $line == *"Run status group"* ]]; then
if [[ $first -eq 0 ]]; then
first=1
else
echo -n 、 >> colloct.txt
fi
echo hahahah
read next_line
if [[ $next_line == *"bw="* ]]; then
bw=$(echo $next_line | grep -o 'bw=[0-9.]\+' | awk -F'[= ]' '{print $2}')
echo -n $bw >> colloct.txt
fi
read next_line2
if [[ $next_line2 == *"WRITE:"* ]]; then
echo -n - >> colloct.txt
if [[ $next_line2 == *"bw="* ]]; then
bw=$(echo $next_line2 | grep -o 'bw=[0-9.]\+' | awk -F'[= ]' '{print $2}')
echo -n $bw >> colloct.txt
fi
fi
fi
done
echo >> colloct.txt
echo >> colloct.txt
}
for file in *
do
if [ -f "$file" ]
then
echo "$file:" >> colloct.txt
exec < $file
step1
exec 3<&-
exec < $file
step2
exec 3<&-
fi
done