Hi, i am writing a bash script and i am trying to redirect output to specific fields in a file. I cant seem to find any way of doing this. I have tried to create fields and add to a specific field using the following line
printf "%s\t%s\t%s\t%s\t%s\n" "" "" "$total" "" "" >> study.txt
which works, but when i try to retrieve info from a specific field using the following line:
cat study.txt | awk '{ sum += $1} END {print sum}'
it doesnt give me the sum of field 1, it gives the sum of all fields combined. Can you add to a specific field using awk?
printf "%s\t%s\t%s\t%s\t%s\n" "" "" "$total" "" "" >> study.txt
which works, but when i try to retrieve info from a specific field using the following line:
cat study.txt | awk '{ sum += $1} END {print sum}'
it doesnt give me the sum of field 1, it gives the sum of all fields combined. Can you add to a specific field using awk?