awk queries
Hi,
I have a file that consists of a column as follows: 1111 2222 3333 4444 I use the following to convert to row: awk '{printf("%s,",$0)}' file but the output contains the command prompt at the end. ie: 1111,2222,3333,4444,$ How to have the output without the command prompt? ie: 1111,2222,3333,4444 Thanks in advance. |
Think about why you used printf. Because it doesn't insert a newline.
So you have to insert a newline yourself at the end. Easiest done with a null "print" in an END rule. However that will leave you with a trailing comma - you will need to account for that also. |
You could also have a look at the ORS variable. HINT:-This can be quick and useful but you will need to consider how you know what the last line will be :)
|
All times are GMT -5. The time now is 02:20 PM. |