答案 0 :(得分:1)
#! /usr/bin/sh
# get height, weight from column 4, 5
printf "Input CSV: "
read CSV
DATA_HEIGHT=$( echo $( wc -l $CSV | cut -f1 -d" " )-1 | bc )
HEIGHT=$(
tail -n +2 $CSV |
( while
read line;
do
VAR=`echo $line | cut -d "," -f4` ;
echo $VAR
done;
) | grep -oE '[0-9]+' | paste -s -d + - | bc
)
WEIGHT=$(
tail -n +2 $CSV |
( while
read line;
do
VAR2=`echo $line | cut -d "," -f5` ;
echo $VAR2
done;
) | grep -oE '[0-9]+' | paste -s -d + - | bc
)
printf "\nHeight(in): "
echo $HEIGHT/$DATA_HEIGHT | bc
printf "Weight(lbs): "
echo $WEIGHT/$DATA_HEIGHT | bc