Sed question

I have following input:

almantas 31949 1 0 00:00:08 ? /usr/bin/pulseaudio -D --log-target=syslog
almantas 31979 12082 0 00:00:06 pts/2 bash
almantas 31991 31949 0 00:00:00 ? /usr/lib/pulseaudio/pulse/gconf-helper
almantas 32009 1 0 00:00:06 ? /usr/lib/libgconf2-4/gconfd-2
almantas 32166 31352 0 00:00:00 ? /usr/bin/seahorse-agent --execute x-session-manager

I need to replace one or more spaces with colon ":"
Syntax would be sed 's/ \+/:/g'
But i don't want to replace all spaces, just first six . I could do something like this sed 's/ \+/:/1' | sed 's/ \+/:/1' | sed 's/ \+/:/1' | sed 's/ \+/:/1' | sed 's/ \+/:/1' | sed 's/ \+/:/1'
How do i make sed repeat only 6 times? Like sed 's/ \+/:/1,2,3,4,5,6' :slight_smile:

Output should be
almantas:31949:1:0:00:00:08:?:/usr/bin/pulseaudio -D --log-target=syslog
almantas:31979:12082:0:00:00:06:pts/2:bash
almantas:31991:31949:0:00:00:00:?:/usr/lib/pulseaudio/pulse/gconf-helper
almantas:32009:1:0:00:00:06:?:/usr/lib/libgconf2-4/gconfd-2
almantas:32166:31352:0:00:00:00:?:/usr/bin/seahorse-agent --execute x-session-manager

With awk:

 awk '{gsub(" ",":",$1)}1' FS=/ OFS=/ file

Regards

thanks, but as you see, in the second line there are no leading slash "/" before word "bash" and this script leaves space there :
almantas 31979 12082 0 00:00:06 pts/2 bash

 awk '
{ for ( n = 1; n <= 6; ++n ) sub(/ /,":"); print }
'