I would like to multiply a single column in a .txt file by a variable and then write to another .txt file. What am I missing from the awk
line? Appreciate any help in advance.
!/bin/bash
FILES=/path/to/files
for f in ${FILES}
do
echo $f
wc -l $f
B=10000000
TOTALLINES="$(wc -l $f | cut -f1 -d' ')"
echo "TOTALLINES: ${TOTALLINES}"
SCALINGFACTOR=$(echo "100000000 / $TOTALLINES" | bc -l)
echo "scaling_factor: ${SCALINGFACTOR}"
awk '{printf($1"\t"$2"\t"$3"\t"$4 * "${SCALINGFACTOR}")}' $f"_prepped.txt" > $f"_normalized.txt"
done