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