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.

Required fields*

4
  • I think I'll go with your solution. But stupid question, shall I use awk... < myfile..., cat myfile | awk..., or...? I can't seem to get desired output using those. (and awk ... myfile doesn't insert lines as well) Commented May 5, 2015 at 17:01
  • It seems that n (not N) is empty when I test it using else and printing it. I don't know much about awk, should variable be initialized beforehand? Commented May 5, 2015 at 17:12
  • Ok, that should be enough spam for today: It seems my awk doesn't support curly braces in regex. I'll google some more. Thank you! Commented May 5, 2015 at 17:31
  • @Misiur, that'll be an old version of gawk where {} were not enabled unless in POSIX compatibility mode. Best is to use the POSIXLY_CORRECT=1 like in my update to make it work without affecting compatibility with other awk implementations. Commented May 5, 2015 at 20:01