Example1:
# sed -n '/21600 1 4/, /^}/ {/^{/p;}' demand.dat > test1
# awk '$2 == "11220" { x += $4 } END { print "total flow per interval: " x "\ntotal flow per hour: " x*4}' test1
Note:
- In the first line, 21600 is the time stamp, 1 is the type, 4 is the scale.
- In the second line, 11220 is the Node ID.
Example2:
# awk -f count_orig.awk orig=11220 Demand/demand_newpath_Xhat_0600.dat
Use script count_orig.awk, whose contain is the following:
$2 == orig { x += $4; print $2 "\t" $3 "\t" $4 }
END { print "total flow per interval: " x "\ntotal flow per hour: " x*4}
Note: "Demand/demand_newpath_Xhat_0600.dat" is the demand file for 6am.