Article 5CGTC awk NR% - mayday mayday

awk NR% - mayday mayday

by
czezz
from LinuxQuestions.org on (#5CGTC)
Here is an input.out file:
Code:cat input.out
Line1
Line2
Line3
Line4
Line5
Line6
Line7
Line8
Line9
Line10
Line11
Line12With following awk I transform this file into follwoing:
Code:cat input.out | awk 'NR%2 !=0 {oddline=$0}; NR%2 == 0 {evenline=$0; print "TAG:"evenline":"oddline};'
TAG:Line2:Line1
TAG:Line4:Line3
TAG:Line6:Line5
TAG:Line8:Line7
TAG:Line10:Line9
TAG:Line12:Line11However, what I want to get is:
Code:TAG:Line3:Line2:Line1
TAG:Line6:Line5:Line4
TAG:Line9:Line8:Line7
TAG:Line12:Line11:Line10What I came up with is this and I cant find the logic how to use NR - can anybody help here please? (it doesnt need to be awk)
Code:cat input.out | awk 'NR%3 != 0 {third=$0}; NR%2 !=0 {oddline=$0}; NR%2 == 0 {evenline=$0; print "TAG:"third":"evenline":"oddline};'
TAG:Line2:Line2:Line1
TAG:Line4:Line4:Line3
TAG:Line5:Line6:Line5
TAG:Line8:Line8:Line7
TAG:Line10:Line10:Line9
TAG:Line11:Line12:Line11latest?d=yIl2AUoC8zA latest?i=se6h-h5iuz0:TRiu0iSiJmA:F7zBnMy latest?i=se6h-h5iuz0:TRiu0iSiJmA:V_sGLiP latest?d=qj6IDK7rITs latest?i=se6h-h5iuz0:TRiu0iSiJmA:gIN9vFwse6h-h5iuz0
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments