Quote:
Originally Posted by vgersh99
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).
|
Thank you Sir,
Minor change; need output comma seperated.
I have tried this but has syntax error.
Code:
nawk '{ORS=(FNR%2)?FS:RS}; OFS=,' temp