Command to arrange vertical list in a horizontal manner
Let's say, I have a file, containing following entries:
Jack Smith William Rose Peter ..... And I want to arrange these entries in a horizontal manner, seperated by space or any other seperator, like this: Jack Smith William Rose Peter.... So how can I achieve this. Please suggest any simple command or awk script. Thanks in advance! |
Code:
tr '\n' ' ' <file.txt |
Code:
awk 'ORS=" "' file |
Quote:
Jack Smith William Rose Peter user@example.com So how to seperate the output and prompt, so it print the prompt in new line? |
Quote:
Jack Smith William Rose Peter user@example.com So how to seperate the output and prompt, so it print the prompt in new line? |
Code:
awk 'ORS=" "' file.txt && or Code:
awk 'ORS=" "' /home/teckk/SteelWeight.txt && ' ' Code:
awk 'ORS=" "' /home/teckk/SteelWeight.txt && echo done |
I am not sure if you are asking a question there or not?
If you are using &&, you will need to provide the next task, ie. ' ' would not be appropriate but your echo should be fine. However, I would point out that unless there is an error in your awk script code it will never not go past && as it always returns true. |
Quote:
awk 'ORS=" "' filename && echo tr '\n' ' ' filename && echo |
Quote:
The same thing will happen with any output that does not include a trailing newline. As shown, following up with a simple && echo solves that problem. |
paste -d, -s <file>
here , is my delimiter. |
All times are GMT -5. The time now is 04:46 PM. |