Create a free Team What is Teams? Learn more. Ask Question. Asked 4 years, 7 months ago. Active 4 years, 7 months ago. Viewed 6k times. I've put together an example using the AWK getline function and it's confusing me. So my expected output is: bar foo baz bar baz I think understanding how changing NR while in the awk loop is the key to understanding this output. Can you explain why my expected output is wrong and why the actual output is right? I'm running awk version on macOS Improve this question.
Add a comment. Active Oldest Votes. Improve this answer. But getline increases NR and reaching the end of each invocation also increments NR so there really is only 2 invocations!
Wow, this is very subtle. However there are people much more knowledgeable in awk than me on here - let's see if one of them chimes in. Gilles 'SO- stop being evil' Gilles 'SO- stop being evil' k gold badges silver badges bronze badges.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Chris Seymour It's generally excepted that getline usually isn't the best approach awk.
Have a look at my answer here for an example stackoverflow. Make that awk. Add a comment. Active Oldest Votes. Improve this answer. Ed Morton Ed Morton k 17 17 gold badges 66 66 silver badges bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked 0. Related
0コメント