![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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' ![]() Output should be almantas:31949:1:0:00:00:08:?:/usr/bin/pulseaudio -D --log-target=syslog almantas:31979:12082:0:00:00:06 ts/2:bashalmantas: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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|