Please I have a text file separated by spaces. I would like to output it to columns separated by ;
example Input
31561 49215 10 1196825801480000 31561 49219 12 1196825801480000 31561 48665 14 1196825806980000
I use this code
tr " " ";" < file
My output
31561;49215;10;;;1196825801480000 31561;49219;12;;;1196825801480000 31561;48665;14;;;1196825806980000
Output desired.
31561;49215;10;1196825801480000 31561;49219;12;1196825801480000 31561;48665;14;1196825806980000
Appreciate your help.
Advertisement
Answer
awk -v OFS=';' '{$1=$1}1' file
$1=$1
is a trick to rebuild $0
with the new separator OFS=';'
.