Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • I tried to make it into one line awk -F, -v min_secs=2000 ' {while (NR + shift < $1) {print (NR + shift) ",NA,NA,NA,NA" shift++}print} END {while (NR + shift <= min_secs) {print (NR + shift) ",NA,NA,NA,NA" shift++}} ' wrong.txt > fixed.txt and then ran it, however it didn't add the new line 166,1.09424,240,76,132 168,1.10088,215,76,132 169,1.10765,213,78,131 170,1.11458,198,79,131 but it also added a bunch at the end - as a test I used a small sample file that stops at 300 lines 300,2.08307,331,58,111 301,2.08754,361,60,112 301,NA,NA,NA,NA1 302,NA,NA,NA,NA2 Commented Feb 16, 2019 at 2:57
  • Oh that doesn't format very well - you can see I'm a noob! Commented Feb 16, 2019 at 2:58
  • @SteveShiny If you're squeezing it all into a one-liner (which I don't recommend for clarity reasons), you have to put the semicolons between the print and shift++ statements back in. That's why you're seeing increasing serial numbers at the end of each dummy line: print thinks shift++ is another argument to it, instead of an entirely separate statement. Commented Feb 16, 2019 at 3:02
  • I'm doing something wrong. I copied and pasted the command, and got the same result. I'm on Mac if that makes a difference? Commented Feb 16, 2019 at 3:39
  • Actually I partially take that back... it found one missing point and added a line for that, but not another 223,1.59792,373,68,110 224,1.60427,373,66,109 225,NA,NA,NA,NA 226,1.61923,373,63,110 227,1.62166,373,60,110 165,1.08769,223,77,131 166,1.09424,240,76,132 168,1.10088,215,76,132 169,1.10765,213,78,131<br/>grrr how to do new lines? Commented Feb 16, 2019 at 3:43