I am trying to delete the 5th coloumn from tst_file, tried with the below command it doesnt give the desired o/p.
Need to acheive this using awk.
Please help
This sets the FS and OFS in the BEGIN section, so they are only set once and work on the first line. It then replaces the first occurrence of two field separators by one, which could be imprecise if any of the first fields can be empty as well.
If there are more than 6 columns, then the - must be added at the end indeed. In fact it is a better general solution, since it also works with exactly 6 columns. I adjusted the second solution. The 1 can be removed or left as is, that is a matter of preference.
The suggestions do not work because they were created for the output sample you posted in post#1. The output format in your last post has a different format, so then it will not work.
No that is OK, I misread your post, I thought you were surprised it did not work. But I see now it did work, but you would like to know what needs to be done to obtain different output.