Quote:
Originally Posted by zenith
Thank you pro
Code:
paste -d' ' - - < temp
nawk 'ORS=(FNR%2)?FS:RS' temp
Would appreciate if you can explain this.
|
You can read the man pages for 'paste' to give you a high-level of what it does - the rest should be easy.
awk:
Code:
(FNR%2) - get a 'modulo' of the current file RecordNumber (FNR) over 2 - every OTHER line.
If the mod is NON-zero, return 'FS' (FieldSeparator)
If the mod is zero, return RecordSeparator (RS)
ORS= - assign the returned value to the OutputRecordSeparator (ORS)
In other words...
If we're dealing with the ODD record/line numbers (1,3,5,7 etc), print the line and FS (separate the next line)
If we're dealing with the EVEN record/line numbers (2.4.6.8 etc), print the line and the ORS (which is by default is newLine).