mirror of
https://github.com/openhwgroup/cvw.git
synced 2025-06-28 17:43:09 -04:00
Fix SeparateBranch.sh script (and hopefully improve robustness long term)
This commit is contained in:
parent
701c0d09c6
commit
e7e85d5b03
1 changed files with 14 additions and 15 deletions
|
@ -3,7 +3,7 @@
|
||||||
###########################################
|
###########################################
|
||||||
## Written: rose@rosethompson.net
|
## Written: rose@rosethompson.net
|
||||||
## Created: 12 March 2023
|
## Created: 12 March 2023
|
||||||
## Modified:
|
## Modified: 15 April 2025 jcarlin@hmc.edu
|
||||||
##
|
##
|
||||||
## Purpose: Converts a single branch.log containing multiple benchmark branch outcomes into
|
## Purpose: Converts a single branch.log containing multiple benchmark branch outcomes into
|
||||||
## separate files, one for each program.
|
## separate files, one for each program.
|
||||||
|
@ -31,27 +31,26 @@
|
||||||
################################################################################################
|
################################################################################################
|
||||||
|
|
||||||
File="$1"
|
File="$1"
|
||||||
TrainLineNumbers=`cat $File | grep -n "TRAIN" | awk -NF ':' '{print $1}'`
|
TrainLineNumbers=$(grep -n "TRAIN" "$File" | awk -NF ':' '{print $1}')
|
||||||
BeginLineNumbers=`cat $File | grep -n "BEGIN" | awk -NF ':' '{print $1}'`
|
Name=$(grep -n "BEGIN" "$File" | awk -NF '/' '{print $7_$5}')
|
||||||
Name=`cat $File | grep -n "BEGIN" | awk -NF '/' '{print $6_$4}'`
|
EndLineNumbers=$(grep -n "END" "$File" | awk -NF ':' '{print $1}')
|
||||||
EndLineNumbers=`cat $File | grep -n "END" | awk -NF ':' '{print $1}'`
|
|
||||||
echo $Name
|
|
||||||
echo $BeginLineNumbers
|
|
||||||
echo $EndLineNumbers
|
|
||||||
|
|
||||||
NameArray=($Name)
|
echo Name: "$Name"
|
||||||
TrainLineNumberArray=($TrainLineNumbers)
|
echo TrainLineNumbers: "$TrainLineNumbers"
|
||||||
BeginLineNumberArray=($BeginLineNumbers)
|
echo EndLineNumbers: "$EndLineNumbers"
|
||||||
EndLineNumberArray=($EndLineNumbers)
|
|
||||||
|
mapfile -t NameArray <<< "$Name"
|
||||||
|
mapfile -t TrainLineNumberArray <<< "$TrainLineNumbers"
|
||||||
|
mapfile -t EndLineNumberArray <<< "$EndLineNumbers"
|
||||||
|
|
||||||
OutputPath=${File%%.*}
|
OutputPath=${File%%.*}
|
||||||
mkdir -p $OutputPath
|
mkdir -p "$OutputPath"
|
||||||
Length=${#EndLineNumberArray[@]}
|
Length=${#EndLineNumberArray[@]}
|
||||||
for i in $(seq 0 1 $((Length-1)))
|
for i in $(seq 0 1 $((Length-1)))
|
||||||
do
|
do
|
||||||
CurrName=${NameArray[$i]}
|
CurrName=${NameArray[$i]}
|
||||||
CurrTrain=$((${TrainLineNumberArray[$i]}+1))
|
CurrTrain=$((${TrainLineNumberArray[$i]}+1))
|
||||||
CurrEnd=$((${EndLineNumberArray[$i]}-1))
|
CurrEnd=$((${EndLineNumberArray[$i]}-1))
|
||||||
echo $CurrName, $CurrTrain, $CurrEnd
|
echo "${CurrName}", "${CurrTrain}", "${CurrEnd}"
|
||||||
sed -n "${CurrTrain},${CurrEnd}p" $File > $OutputPath/${CurrName}_${File}
|
sed -n "${CurrTrain},${CurrEnd}p" "$File" > "${OutputPath}/${CurrName}_${File}"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue