the problem is that column 15 gets to column 1 but it is not comma separated with the initial column 1 ...i.e column 15 and column 1 are getting sort of concatenated with a space as a delimiter....i want a comma...what should i do?
Note that this is making the unstated assumption that each input line always contains exactly 15 fields. The original code seemed to be trying to end up with 15 fields no matter how many were present in the input.
The awk script here moves the fifteenth (possibly empty) field to the start of output line, but may end up with one or more output fields depending on the number of input fields.
I agree that decreasing NF is not guaranteed to work with every awk (for example it works with nawk on Solaris, but not with /usr/xpg4/bin/awk ) ,
however, it does seem to modify $0 in my version of awk on OSX ( bwk version 20070501 )
---
IF there are exactly 15 columns, one could try: