Hi All,
I have a bedgraph file with 4 columns - Chr, Start, End, Value.
I want to go through the 4th column and sum each row in that column until I have reached a certain value then print that row.
so for instance - Sum column until you a reached a value of 100 then print that entire line
I have done a little scripting but I just can't think how to do this. If someone could help me with an AWK command that would do this that would be great. If you ha the time to break down & explain the command a little that would be a bonus!
Thank you
I would strongly advise a new programmer against using numerical variables that will have their values changed during runtime, without explicit initialization.
I never understood the point of the BEGIN block. The above works just as well without it too..
If you're writing stuff to be reused, or at least self-documenting, initializing variables seems like a decent practice.
Inside some script/program.. sure. But as one-liner..
Perhaps your variable is already set where you need it. The "s" here may start at zero without initializing it. I often have to use BEGIN to set the field separators before reading anything.