Reputation: 55
Hi i ve been trying to read records from a final_customer_total.txt which contains details like size of processed files. I used "nawk" command to read the final_customer_total.txt to calculate total size processed and then store the total sum into another file .
variable t= size of unprocessed files
for example let
t=1000
input file :
file1 100
file2 250
file3 300
expected output:
Total size needs to be processed : 1650
actual output:
file1 100
file2 250
file3 300
Total size needs to be processed : 1650
my concern content of inupt file also coming in output which i dont want!!
below is the command i tried
cat final_customer_total.txt |nawk '{total = total + $1} END{printf ("\nTotal size :"(total + t)/1024/1024/1024" GB")}'t=$t >>customer_total_size.txt
when i tried with "awk" its getting errored
Error :awk bailing out near line 1
Upvotes: 0
Views: 1665
Reputation: 30843
I suspect what you want to be:
nawk -v t=$t '
{
total = total + $1
}
END {
printf ("Total size needs to be processed: %d GiB\n",(total+t)/1024/1024/1024)
}' final_customer_total.txt > _cts.txt
mv final_customer_total.txt final_customer_total.txt.old
mv _cts.txt final_customer_total.txt
Upvotes: 1