嗨,我一直在尝试从final_customer_total.txt中读取记录,其中包含了一些细节,比如处理过的文件的大小。我使用"nawk“命令读取final_customer_total.txt来计算已处理的总大小,然后将总和存储到另一个文件中。
未处理文件的可变t=大小
例如,让
t=1000
输入文件:
file1 100
file2 250
file3 300
预期输出:
需要处理的总尺寸: 1650
实际输出:
file1 100
file2 250
file3 300
需要处理的总尺寸: 1650
我关心的内容的inupt文件也来输出,我不想!!
下面是我尝试过的命令
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当我尝试使用"awk“时,它变得错误了。
错误:awk在第1行附近救助
发布于 2012-01-21 16:50:17
我怀疑你想成为什么样的人
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.txthttps://stackoverflow.com/questions/8699893
复制相似问题